访问localhost /时,IIS Express不承担localhost / index.html

时间:2013-12-17 17:28:51

标签: visual-studio iis visual-studio-2013 iis-express

如何让localhost /指向localhost / index.html?

直接访问index.html可以正常工作,但在访问站点根目录时,我收到以下错误:

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

我查看了IIS Express配置文件(%userprofile%\ documents \ iisexpress \ config \ applicationhost.config),但看不出有什么问题。

这是我项目的虚拟目录信息:

<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>

<system.webServer>部分,它包括:

<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 个答案:

答案 0 :(得分:7)

我添加了routes.IgnoreRoute(“”);在RouteConfig.cs中允许localhost /提供localhost / index.html。有人知道为什么会这样吗?

答案 1 :(得分:1)

检查globalModules列表中是否有defdoc模块。

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