user3071284
user3071284

Reputation: 7100

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>

Upvotes: 5

Views: 7004

Answers (2)

user3071284
user3071284

Reputation: 7100

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

Upvotes: 7

vikomall
vikomall

Reputation: 17519

check if you have defdoc module in the globalModules list.

<globalModules> 
<add name="DefaultDocumentModule" image="...\defdoc.dll" />
......
</globalModules>

Upvotes: 1

Related Questions