我们在负载均衡器后面的 Win 2012 R2 上的 IIS 8.5 上运行 Owin 应用程序。在某些情况下,对某些 URL 的请求会无限期地挂起。如果用户在浏览器中选择取消,并重新加载页面,则一切正常并且服务器响应很快。
In IIS manager, we can see the requests hanging:
The hang seems to occur inside the Owin pipeline. We are running .NET 4.5.2 and the latest Owin packages.
这是代码/api/whoami
端点:
[Authorize]
public class WhoAmIController : ApiController
{
[Route("whoami")]
[HttpGet]
public IHttpActionResult Whoami()
{
return Json(ClaimsPrincipal.Current.Identity.Name);
}
}
观察结果是,对此端点的请求挂在AuthenticateRequest
IIS 管道中的阶段,而不是PreExecuteRequestHandler
这是 OWIN 管道的默认 IIS 阶段。我们唯一的身份验证方法是cookie身份验证,它在AuthenticateRequest
stage.
有任何想法吗?
编辑:调整截图
问题是我们在 IIS 事件上执行代码PreSendRequestHeaders
,根据http://www.asp.net/aspnet/overview/web-development-best-practices/what-not-to-do-in-aspnet,-and-what-to-do-instead#presend http://www.asp.net/aspnet/overview/web-development-best-practices/what-not-to-do-in-aspnet,-and-what-to-do-instead#presend
我们的目的是在所有请求发出时调整 HTTP 标头。解决方法是将代码移至BeginRequest
event.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)