6

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).

Fiddler Intellitrace

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>
3
  • show us code that generates an error. It doesn't have to be your code; it just needs to reproduce the problem. Commented Mar 23, 2016 at 19:20
  • There is no code generating the error. In the example I made a request to https://localhost:44300, and IIS directly returns a 403 status code. It's the same if I make a request to an non-existent endpoint (e.g. localhost:44300/somethingnonexisting), and IIS returns a 404. Commented Mar 23, 2016 at 19:25
  • Also note that at the moment there is nothing else in the Owin pipeline, just the middleware showed in the example. Commented Mar 23, 2016 at 19:44

1 Answer 1

3

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>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.