2015-06-19 91 views
6

我正在使用ASP.NET 5,其中整個文件夾結構被更改並且web.config被替換(與以前的ASP.NET版本相比)。我做的客戶端使用angularJS路由和我有這樣的路線:ASP.NET 5中的URL重寫

.when('/movies/add', { 
      templateUrl: '/Views/add.html', 
      controller: 'MoviesAddController' 
     }) 

一切工作的渴望,我開始在我的index.html,然後點擊一個鏈接到/電影上/添加。如果我使用/電影重新加載頁面/添加URL,服務器給了我404根據這個教程中,我應該在web.config中做一個重寫,像這樣:

<!-- from http://stackoverflow.com/questions/25916851/wrapping-staticfilemiddleware-to-redirect-404-errors --> 

<configuration> 
<system.webServer> 
    <modules runAllManagedModulesForAllRequests="true" /> 
    <rewrite> 
    <rules> 
     <!--Redirect selected traffic to index --> 
     <rule name="Index Rule" stopProcessing="true"> 
     <match url=".*" /> 
     <conditions logicalGrouping="MatchAll"> 
      <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> 
      <add input="{REQUEST_URI}" matchType="Pattern" pattern="^/api/" negate="true" /> 
     </conditions> 
     <action type="Rewrite" url="/index.html" /> 
     </rule> 
    </rules> 
    </rewrite> 
</system.webServer> 
</configuration> 

我使用IIS快遞10.0 (在Windows 10預覽中)。我知道web.config中的部分應該仍然存在於ASP.NET 5中來配置IIS,但我沒有從中得到任何結果。 我是否需要使用IIS Express做一些不同的事情? ASP.NET 5中提供了另一個更一般的解決方案嗎?

謝謝!

+0

告訴你的web.config中已經回答了我:) – CularBytes

回答