I noticed a strange behavior while debugging an ASP.NET Web Application (.NET 4.6.1). Whenever an HTTP error occurs (e.g. 404 or 403) the request get duplicated up to a total of 3 times.
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).
I can see the effects of this issue because any Owin middleware in the pipeline is invoked three times. A simple middleware like this:
app.Use(async (c, n) =>
{
Debug.WriteLine("HIT!");
await n.Invoke();
});
Will print three consecutive "HIT!" into the console.
This happens only if the request generates an error, and not if the request is handled by a middleware (e.g. not if the middleware responds with a 2XX status code).
What's going on?
I'm running VS2015 and IIS Express 10 on Win10.
[EDIT] It may be related to my Web.config configuration? 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. I solved it by removing them in 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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With