小编Sta*_*dup的帖子

Azure 可用性测试和运行状况测试有什么区别

如果您转到 Azure webapp,并在左侧面板上选择Application Insights。然后View Application Insights Data单击Availability左侧面板上的 ,您可以添加新的测试。基本上,您可以在此处指定站点的运行状况/ping 端点。您还可以在此处配置警报的一些关联规则。

现在,Azure 有了一个新功能,可以Health Check在 Web 应用程序上调用。您所要做的就是启用它,并为其提供您的运行状况/ping 端点。然后你也可以在这里配置规则。

使用这两种方法,运行状况端点均由 azure 触发,如果根据警报规则出现问题,您会收到警报消息。

但这两种方法有什么区别呢?

azure azure-web-app-service azure-devops

8
推荐指数
1
解决办法
1111
查看次数

为什么按钮上的光标没有变化

我不确定为什么光标没有变成按钮上的指针。我看到一些解决方案说这是因为z-index. 但是当我尝试使用时z-index,它仍然不起作用。

.upload-btn-wrapper {
  position: relative;
  overflow: hidden;
  display: inline-block;
}

.btn {
  border: 2px solid gray;
  color: gray;
  background-color: white;
  padding: 8px 20px;
  border-radius: 8px;
  font-size: 20px;
  font-weight: bold;
}

.upload-btn-wrapper input[type=file] {
  font-size: 100px;
  position: absolute;
  left: 0;
  top: 0;
  opacity: 0;
  cursor: pointer;
}
Run Code Online (Sandbox Code Playgroud)
<div class="upload-btn-wrapper">
  <button class="btn">Upload a file</button>
  <input type="file" name="myfile" />
</div>
Run Code Online (Sandbox Code Playgroud)

谢谢你的帮助。

我从这个codepen中作弊:

https://codepen.io/adambene/pen/xRWrXN

html css

5
推荐指数
2
解决办法
1万
查看次数

如何在静态类中使用 NLog,其中其他所有内容都与 Autofac 连接

我的 MVC 应用程序与 Autofac 连接。我还配置了 NLog,它在我的控制器类中按预期工作。我的nLogger注册如下:

var builder = new ContainerBuilder();
builder.RegisterGeneric(typeof(LoggerService<>))
  .As(typeof(ILoggerService<>)).SingleInstance();
var container = builder.Build();
Run Code Online (Sandbox Code Playgroud)

ILoggerService 的构造函数是:

public LoggerService()
{
    SourceClass = typeof (T).FullName;
    Logger = LogManager.GetLogger(SourceClass);
 }
Run Code Online (Sandbox Code Playgroud)

现在我也有很多我使用的静态帮助器类。例如:

public static class Helper
{
   public static string GenerateQrBitmap(string secret, string issuer, string userEmail)
   {
     ...
   }
}
Run Code Online (Sandbox Code Playgroud)

但我也希望能够在这些 Helper 类中使用记录器。

c# model-view-controller nlog autofac

3
推荐指数
1
解决办法
3326
查看次数

条纹:获取信用卡的最后4位数字

我已经将Stripe.net升级到了最新版本20.3.0,但是现在我似乎找不到信用卡的.Last4。我有以下方法:

    public void CreateLocalCustomer(Stripe.Customer stipeCustomer)
    {
        var newCustomer = new Data.Models.Customer
        {
            Email = stipeCustomer.Email,
            StripeCustomerId = stipeCustomer.Id,
            CardLast4 = stipeCustomer.Sources.Data[0].Card.Last4
        };

        _dbService.Add(newCustomer);

        _dbService.Save();
    }
Run Code Online (Sandbox Code Playgroud)

但是现在stipeCustomer.Sources.Data[0].Card.Last4说了'IPaymentSource' does not contain a definition for 'Card'。有人知道我现在如何获得卡的详细信息吗?流程是,我通过将Stripe令牌传递给Stripe来创建客户,然后得到上面的stripeCustomer。因此,我希望它位于该对象的某个位置。但是我找不到。发行说明可以在这里找到。谢谢。

stripe-payments

2
推荐指数
1
解决办法
1218
查看次数

Azure 每 5 分钟点击一次 Web 应用程序主页

我在 Azure 上有一个 Web 应用程序,看起来 App Insights 或某些监控每 5 分钟就会对我的主页执行 ping 操作。

现在我已经在主页添加了日志记录来记录访问详细信息,这只是令人烦恼。

我能做些什么吗?我尝试通过执行以下操作来排除这些 ping:

var userHostIp = Request.UserHostAddress;
if ((string.IsNullOrEmpty(userHostIp) || !userHostIp.Equals("::1")))
{
   Logger.Log("Page Visited: Home page");
}
Run Code Online (Sandbox Code Playgroud)

由于我在日志中看到的 IP 地址是::1,但这也不起作用。

asp.net-mvc azure azure-web-app-service

2
推荐指数
1
解决办法
1387
查看次数

如何正确执行 DateTime.Parse

我有以下方法:

    private DateTime GetDateTimeFromString(string dateTimeStr)
    {
        try
        {
            return DateTime.Parse(dateTimeStr, CultureInfo.InvariantCulture);
        }
        catch (Exception ex)
        {
            _logger.Log($"Exception while parsing {dateTimeStr}: {ex.Message}.");

            return DateTime.Now;
        }
    }
Run Code Online (Sandbox Code Playgroud)

当我在 Visual Studio 中运行它时,它工作正常。但是当它部署到 Azure 时它失败了。错误是:

解析 21/4/2019 11:6:56 时出现异常:String 未被识别为有效的 DateTime。

我在调试器中粘贴21/4/2019 11:6:56,它有效。醉了。有人可以帮忙吗?

请注意,无论是否使用 CultureInfo,它都会在 Azure(作为 Web 应用程序)上失败。

同样在 Azure 上,我的 web.config 设置为:

<globalization culture="" uiCulture="" />
Run Code Online (Sandbox Code Playgroud)

c# datetime tryparse

1
推荐指数
1
解决办法
242
查看次数

如何修复Encoding.ASCII.GetBytes的意外输出

我在Encoding.ASCII.GetBytes方法的输出中看到意外的字符(?)。

因此,我正在执行以下操作:

var stringBytes = Encoding.ASCII.GetBytes(myString);
Run Code Online (Sandbox Code Playgroud)

myString在哪里:

{
  "$id": "1",
  "Note": "<p><span style=\"font-family: &quot;Courier New&quot;;\">?aaaa</span> 
  <br></p>"
}
Run Code Online (Sandbox Code Playgroud)

现在,如果我这样做:

var myString1 = System.Text.Encoding.Default.GetString(stringBytes)
Run Code Online (Sandbox Code Playgroud)

然后,myString1返回为:

{
  "$id": "1",
  "Note": "<p><span style=\"font-family: &quot;Courier New&quot;;\">? 
   aaaa</span><br></p>"
}
Run Code Online (Sandbox Code Playgroud)

请注意,在最后一次操作中,aaaa如何转换为?aaaa

有人可以告诉我我在这里想念的吗?谢谢。

c#

0
推荐指数
1
解决办法
41
查看次数