我将以下内容编辑到 Program.cs
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.ConfigureLogging((hostingContext, logging) =>
{
logging.AddConfiguration(hostingContext.Configuration.GetSection("Logging"));
logging.AddEventLog(eventLogSettings =>
{
eventLogSettings.SourceName = "MyTestLog";
});
});
webBuilder.UseStartup<Startup>();
});
Run Code Online (Sandbox Code Playgroud)
并将一些示例日志写入控制器
public IEnumerable<WeatherForecast> Get()
{
_logger.LogCritical("Critical Log");
_logger.LogError("Error Log");
_logger.LogWarning("Warning Log");
_logger.LogInformation("Info Log");
_logger.LogDebug("Debug Log");
_logger.LogTrace("Trace Log");
...
}
Run Code Online (Sandbox Code Playgroud)
如果我运行它,它会在控制台中显示“严重”-“错误”-“警告”-“信息”的日志。与 AppSettings 中配置的内容匹配。
应用程序设置.json:
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}
Run Code Online (Sandbox Code Playgroud)
在 Windows 事件日志中,它仅显示严重、错误和警告日志,而不关心我的应用程序设置。我确信这是一个简单的配置问题,但我没有找到任何相关文档。
如何获取 Windows …
我已经在Azure App Service上托管了一个Asp.NET MVC应用程序。我收到了超过230秒的超时异常。如何在Azure App Service上增加它?
我们将一些 Web 项目更改为 SDK 样式,但是如果我们在 Visual Studio 中启动该项目,它不会启动浏览器。IISExpress 命令提示符确实会运行并启动网站,因此当手动访问网站时它可以工作。
使用 SDK 风格的项目时是否可以启动浏览器?(或者是否有解决方法/工具使其成为可能?)。我知道对于 dotnet core 网站,这确实有效,并且启动了新的浏览器实例,也许我们应该保留 .NET Framework Web 项目的旧格式。
启动设置.json
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:29750/",
"sslPort": 0
}
},
"profiles": {
"IIS Express": {
"commandName": "Executable",
"executablePath": "C:\\Program Files\\IIS Express\\iisexpress.exe",
"commandLineArgs": "/path:\"$(SolutionDir)$(ProjectName)\" /port:29750",
"launchBrowser": true,
"launchUrl": "/"
}
}
}
Run Code Online (Sandbox Code Playgroud)
项目,删除了脚本和少量视图
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="Current">
<PropertyGroup>
<TargetFramework>net461</TargetFramework>
<AssemblyName>Web</AssemblyName>
<OutputType>Library</OutputType>
<OutputPath>bin\</OutputPath>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Antlr" Version="3.5.0.2" />
<PackageReference Include="Castle.Windsor" Version="3.4.0" />
<PackageReference Include="Castle.Windsor.Mvc" Version="1.3.0" /> …
Run Code Online (Sandbox Code Playgroud) 我试图将一个对象从客户端传递到集线器:在客户端上:
connection.invoke('MyMethod', {
i: 1,
a: 25
});
Run Code Online (Sandbox Code Playgroud)
在集线器上:
public async Task MyMethod(TestModel model)
{
// logic
}
Run Code Online (Sandbox Code Playgroud)
模型:
public class TestModel
{
[JsonProperty("i")]
public double Min {get;set;}
[JsonProperty("a")]
public double Max {get;set;}
}
Run Code Online (Sandbox Code Playgroud)
在 MyMethod 中,模型不为 null,但值始终为 0。
我做错了什么?
asp.net-core ×2
.net ×1
asp.net ×1
asp.net5 ×1
azure ×1
c# ×1
event-log ×1
javascript ×1
logging ×1
signalr ×1