Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IIS 8 - Default Document - resource cannot be found

I'm trying to understand why my default document doesn't come up when I browse the virtual directory. If I browse to the site like I should be able to, I get this:

enter image description here


However, if I add the page to the URL, it comes up:

enter image description here


One SO answer suggested removing all of the default documents (in IIS) except the real one. I tried that (image below) but it didn't help.

enter image description here


Why won't IIS serve that page when using the root URL (http://localhost/SignalRChat)?

This is the relevant part of the web.config after removing the default docs:

<defaultDocument>
    <files>
        <remove value="default.aspx" />
        <remove value="iisstart.htm" />
        <remove value="index.html" />
        <remove value="index.htm" />
        <remove value="Default.asp" />
        <remove value="Default.htm" />
        <add value="ChatPage.cshtml" />
    </files>
</defaultDocument>

This is the handlers section:

<handlers>
  <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
  <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
  <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
  <add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*."
       verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS"
       modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll"
       preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
  <add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*."
       verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS"
       modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll"
       preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
  <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*."
       verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler"
       preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
like image 982
Bob Horn Avatar asked Jun 01 '13 20:06

Bob Horn


2 Answers

Another possible reason of the 404 error when your request doesn't point to a specific file name at the end of URL is that your IIS Request Filtering rules deny extensionless requests.

To know it for sure, figure out the subcode of the 404 error. Usually, it's 404.7, but there may be some variations,

Also, you can try to allow extensionless requests explicitly by adding <add fileExtension="." allowed="true" /> to your web.config as below:

  <system.webServer>
    <security>
      <requestFiltering>
        <fileExtensions>
          <add fileExtension="." allowed="true" />
        </fileExtensions>
      </requestFiltering>
    </security>
  </system.webServer>

Please let me kniw if it helped or post your exact 404 error with the subcode.

like image 83
Alexander Abakumov Avatar answered Nov 09 '22 10:11

Alexander Abakumov


From your tags it looks like you use MVC and a view using the razor view engine (cshtml). In MVC an URL does not map to a document directly. So the discussion should not be about default documents, handlers and IIS configuration.

An URL must match a defined route, which invokes an action on a controller. This action will then render the view (*.cshtml).

Try to fix your routes to be able to handle the request. If you need more help, you should update your question with more information about the controller and your routes.

like image 38
studert Avatar answered Nov 09 '22 10:11

studert