我有SPA Angular 6应用程序与asp.net核心2.1一起运行。不可预知的是,对api控制器的http请求永远不会得到响应。当我查看浏览器调试时,它将请求显示为“挂起”。所以我添加了一些中间件:
public static void UseRequestLogger(this IApplicationBuilder app) {
app.Use(async (context, next) =>
{
var logger = context.RequestServices.GetService<ILogger<MyLoggerService>>();
var id = Guid.NewGuid();
logger.LogDebug($"starting request: {context.Request.Path}-{id}");
await next();
logger.LogDebug($"ending request: {context.Request.Path}-{id}");
});
}然后,我在StartUp.cs的Configure方法的顶部调用app.UseRequestLogger()。当我的请求在浏览器中停留在“挂起”状态时,我注意到中间件从未被处理过。我有点不知所措,不知道该怎么做。如果中间件没有受到攻击,那么在此之前会发生什么,我如何检查它?
发布于 2019-01-23 23:37:00
对我来说,同样的配置和同样的不可预知的行为。
除非使用IIS + FireFox中托管的API进行调试(此处仅使用Chrome来调试错误),否则或API自托管(通过launchSettings.json)。
{
...
"profiles": {
"YourProjectName": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "http://localhost:10001"
},
"IIS": {
"commandName": "IIS",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
...
}我的建议是调试你的应用程序和api自托管之间的通信。然后在生产中,您可以在IIS下托管API,根据我的经验,这在发布模式中从未出现过问题。
https://stackoverflow.com/questions/52880732
复制相似问题