[英]Duplicated requests when debugging ASP.NET on IIS Express
I noticed a strange behavior while debugging an ASP.NET Web Application (.NET 4.6.1). 我在调试ASP.NET Web应用程序(.NET 4.6.1)时发现了一种奇怪的行为。 Whenever an HTTP error occurs (eg 404 or 403) the request get duplicated up to a total of 3 times.
每当发生HTTP错误(例如404或403)时,请求就会被复制到最多3次。
I have tested this singular issue using fiddler, and Intellitrace effectively shows me the three identical requests (even if I send just a single request). 我使用fiddler测试了这个单一的问题,Intellitrace有效地向我显示了三个相同的请求(即使我只发送一个请求)。
I can see the effects of this issue because any Owin middleware in the pipeline is invoked three times. 我可以看到这个问题的影响,因为管道中的任何Owin中间件都被调用了三次。 A simple middleware like this:
像这样的简单中间件:
app.Use(async (c, n) =>
{
Debug.WriteLine("HIT!");
await n.Invoke();
});
Will print three consecutive "HIT!" 将打印连续三次“HIT!” into the console.
进入控制台。
This happens only if the request generates an error, and not if the request is handled by a middleware (eg not if the middleware responds with a 2XX status code). 这种情况仅在请求生成错误时发生,而不是在请求由中间件处理时发生(例如,如果中间件以2XX状态代码响应则不会)。
What's going on? 这是怎么回事?
I'm running VS2015 and IIS Express 10 on Win10. 我在Win10上运行VS2015和IIS Express 10。
[EDIT] It may be related to my Web.config configuration? [编辑]它可能与我的Web.config配置有关? I'm adding an excerpt from it.
我正在添加一段摘录。
<system.web>
<compilation debug="true" targetFramework="4.6.1" />
<httpRuntime targetFramework="4.6.1" enableVersionHeader="false" />
</system.web>
<system.webServer>
<httpProtocol>
<customHeaders>
<clear />
</customHeaders>
<redirectHeaders>
<clear />
</redirectHeaders>
</httpProtocol>
<security>
<requestFiltering removeServerHeader="true" />
</security>
<handlers>
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<remove name="OPTIONSVerbHandler" />
<remove name="TRACEVerbHandler" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
<modules runAllManagedModulesForAllRequests="true" />
</system.webServer>
The issue was caused by multiple handlers trying to manage the unhandled request in IIS Express. 该问题是由多个处理程序尝试在IIS Express中管理未处理的请求引起的。 I solved it by removing them in Web.config:
我通过在Web.config中删除它来解决它:
<system.webServer>
<handlers>
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
<remove name="ExtensionlessUrl-Integrated-4.0" />
<remove name="ExtensionlessUrl-ISAPI-4.0_32bit" />
</handlers>
</system.webServer>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.