我正在使用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中提供了另一个更一般的解决方案吗?
谢谢!
告诉你的web.config中已经回答了我:) – CularBytes