5

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>

2 Answers 2

7

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

Sign up to request clarification or add additional context in comments.

1 Comment

It makes sense that it would work -- you're telling MVC to not try to map that path to a specific controller and instead to let it fall back to standard ASP.NET path mapping -- which means that it will try to load the default file specified by IIS.
1

check if you have defdoc module in the globalModules list.

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

1 Comment

The defdoc.dll is there and is not commented out. It looks like <add name="DefaultDocumentModule" image="%IIS_BIN%\defdoc.dll" />

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.