20

We have a problem occuring on some of our developer workstations: when visiting a URL without a filename (e.g. http://localhost/), IIS 7 returns a 404 error. Everyone is running Windows 7/IIS 7.5 and ASP.NET 4.0. The application pool is configured to use Classic pipeline mode.

Default documents are enabled, and default.aspx is in the default document list.

I enabled failed request tracing, and see this in the log:

OldHandlerName="", NewHandlerName="ExtensionlessUrl-ISAPI-4.0_64bit", 
  NewHandlerModules="IsapiModule", 
  NewHandlerScriptProcessor="C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll", NewHandlerType=""

Later on, I see that this IsapiModule is rejecting the request:

ModuleName="IsapiModule", Notification="EXECUTE_REQUEST_HANDLER", HttpStatus="404",
  HttpReason="Not Found", HttpSubStatus="0", 
  ErrorCode="The operation completed successfully. (0x0)", ConfigExceptionInfo="" 

It looks like IIS thinks the ExtensionlessUrl-ISAPI-4.0-64bit should be handling the request. When I look at that module's configuration, it shows that it should be matching path *., so I'm confused why it is matching no path.

A Google search turns up this post on the IIS.net forums from 2005. Unfortunately, no solutions are offered, just an acknowledgement of the problem.

When I update my app pool to use integrated mode, the problem goes away. Unfortunately, it has to run in Classic mode.

What can I do to get IIS to server our default documents again?

Aaron Jensen
  • 25,861
  • 15
  • 82
  • 91
  • 1
    Find out if you've installed Windows7 SP1 or hotfix KB KB980368. I had a few shenanigans with this hotfix (which is rolled into SP1): http://stackoverflow.com/questions/5080837/asp-net-2-0-and-4-0-seem-to-treat-the-root-url-differently-in-forms-authenticatio – Kev Aug 07 '11 at 23:56
  • @Kev Thanks. The knowledge base article you linked to seems to explain the problem I was having. – Aaron Jensen Aug 08 '11 at 22:42
  • Odd, I'm having the same issue, but mine works in Classic Mode but not in Integrated Mode (which I have to use). – Derek Greer Mar 14 '12 at 22:25
  • I just solved this problem by switching the app pool into Integrated Mode. – Michael12345 Apr 02 '13 at 22:39

6 Answers6

23

It looks like Microsoft released an update that enables the ExtensionlessURL HTTP handler to work with extensionless URLs. Unfortunately, this breaks certain other handlers. In my case, the DefaultDocument handler under classic app pools. The solution is to remove the ExtensionlessURL handlers in our application's web.config:

<system.webServer>
  <handlers>
    <remove name="ExtensionlessUrl-ISAPI-4.0_32bit" />
    <remove name="ExtensionlessUrl-ISAPI-4.0_64bit" />
    <remove name="ExtensionlessUrl-Integrated-4.0" />
  </handlers>
</system.webServer>
KyleMit
  • 30,350
  • 66
  • 462
  • 664
Aaron Jensen
  • 25,861
  • 15
  • 82
  • 91
  • 1
    This resolved my same problem where my index.php was not getting called. I had configured an App Pool in Classic mode for a nested Application for running PHP. – John B Nov 15 '12 at 18:30
  • 4
    Note that for me this didn't work - it needed to be "ExtensionlessUrlHandler-Integrated-4.0". – Dylan Nicholson Oct 02 '13 at 23:17
  • This solve the problem I was experiencing. Thanks for posting this as I would have probably never stumbled across this otherwise. Dylan is correct in the string not being precisely exact, but the fact that the handler was interfering with the IIS default document settings is a key find. – Jim Oct 15 '18 at 19:17
15

I solved the problem with putting the "StaticFile" handler in HandlerMapping in front of "ExtensionlessUrlHandler-*"

Tom
  • 151
  • 1
  • 2
  • This worked for me as well. I'm running a mixed website, an old migrated asp.net 2 site alongside MVC5, and after upgrading to MVC5 my default document (strangly enough it's not a static page, my default page is Default.aspx, with a ton of code behind), and moving StaticFile above Extensslessurlhandler-ISAPI-4.0_32bit and the other 2 extensionlessUrlhander's, sorted the problem. Huh! Thank you for this! Please be warned, it makes a total mess of your Web config, as manually "moving" the handler above the other handlers mentioned, will move ALL the handlers listed in your web.config. – snowcode Jun 25 '14 at 17:28
  • This worked for me as well, when the accepted answer did not. In my case, I had an index.html that I wanted to be the main page, but I needed the extensionless handler to keep my web api setup from breaking. – Aaron Averett Mar 14 '18 at 23:56
1

I noticed when removing the managed .NET framework (4.0) from the application pool, it fixed the problem for me too!

We don't use .NET at all in our IIS environment!

R. Hoek
  • 916
  • 8
  • 27
1

I use the following rule in web.config URL Redirect as workaround to solve this:

 <system.webServer>
    <rewrite>
      <rules>
        <rule name="Default document rewrite" stopProcessing="true">
          <match url="^(.+/)?$" />
          <action type="Redirect" url="https://{HTTP_HOST}/default.aspx" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
0

Changing the StaticFile order helped to fix the issue, when setting default document to a web site application in IIS, while the root website also had another default document.

0

Adding the DefaultDocument component to IIS in add/remove windows features and then inserting the name of my default script ( index.php) worked for me.