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:
However, if I add the page to the URL, it comes up:
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.
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>
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.
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.
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