Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IIS Express does not assume localhost/index.html when accessing localhost/

How do I get localhost/ to point to localhost/index.html?

Accessing index.html directly works fine, but when accessing the site root, I get the following error:

Server Error in '/' Application.

The resource cannot be found.

Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly. 

Requested URL: /

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.33440

I looked in the IIS Express config file (%userprofile%\documents\iisexpress\config\applicationhost.config) but don't see what could be wrong.

This is the virtual directory information for my project:

<site name="MySite" id="12">
            <application path="/" applicationPool="Clr4IntegratedAppPool">
                <virtualDirectory path="/" physicalPath="C:\Users\username\path\to\project\projectname" />
            </application>
            <bindings>
                <binding protocol="http" bindingInformation="*:90210:localhost" />
            </bindings>
        </site>

And in the <system.webServer> part, it includes:

<defaultDocument enabled="true">
        <files>
            <add value="Default.htm" />
            <add value="Default.asp" />
            <add value="index.htm" />
            <add value="index.html" />
            <add value="iisstart.htm" />
            <add value="default.aspx" />
        </files>
    </defaultDocument>
like image 371
user3071284 Avatar asked Dec 17 '13 17:12

user3071284


2 Answers

I added routes.IgnoreRoute(""); in RouteConfig.cs to allow localhost/ to serve localhost/index.html. Anyone know why this works?

like image 81
user3071284 Avatar answered Nov 15 '22 07:11

user3071284


check if you have defdoc module in the globalModules list.

<globalModules> 
<add name="DefaultDocumentModule" image="...\defdoc.dll" />
......
</globalModules>
like image 21
vikomall Avatar answered Nov 15 '22 08:11

vikomall