2013-12-17 48 views
5

如何獲取本地主機/指向本地主機/ index.html?IIS Express在訪問本地主機時不承擔本地主機/ 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快遞配置文件(%USERPROFILE%\文件\ 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> 

回答

7

我加了routes.IgnoreRoute(「」);在RouteConfig.cs中允許localhost /爲localhost/index.html提供服務。任何人都知道爲什麼這個工程?

+0

它是有道理的,它會工作 - 你告訴MVC不要試圖將該路徑映射到特定的控制器,而是讓它回退到標準的ASP.NET路徑映射 - 這意味着它會嘗試加載由IIS指定的默認文件。 – BrainSlugs83

1

檢查你在globalModules列表defdoc模塊。

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

defdoc.dll在那裏,沒有被註釋掉。它看起來像「' – user3071284

+0

任何其他的想法? – user3071284