Duplicate Queries When Debugging ASP.NET on IIS Express

I noticed strange behavior when debugging an ASP.NET web application (.NET 4.6.1). Whenever an HTTP error occurs (for example, 404 or 403), the request is duplicated up to 3 times.

I tested this single problem using a script, and Intellitrace effectively shows me three identical requests (even if I send only one request).

Fiddler Intellitrace

I see the effects of this problem because any Owin middleware in the pipeline gets called three times. Simple middleware like this:

app.Use(async (c, n) => { Debug.WriteLine("HIT!"); await n.Invoke(); }); 

Will print three consecutive "HIT!" to the console.

This only happens if the request generates an error, and not if the request is processed by middleware (for example, if the middleware does not respond with a 2XX status code).

What's happening?

I am running VS2015 and IIS Express 10 on Win10.

[EDIT] Perhaps this is due to my Web.config configuration? I am adding a passage 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> 
+5
source share
1 answer

The problem was caused by several handlers trying to manage a raw request in IIS Express. I solved this by deleting 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> 
+2
source

Source: https://habr.com/ru/post/1245654/


All Articles