我使用MVC 6 .NET核心RC2MVC 6,.NET的核心RC2改寫爲index.html的非/ API網址
在我startup.cs我有以下的(因爲大多數人建議):
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.UseDefaultFiles();
app.UseStaticFiles();
app.UseMvc();
}
在我的wwwroot/的web.config文件我:
<configuration>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<handlers>
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified"/>
</handlers>
<httpPlatform processPath="%DNX_PATH%" arguments="%DNX_ARGS%" stdoutLogEnabled="false" startupTimeLimit="3600"/>
<rewrite>
<rules>
<rule name="IndexHomeRule" 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>
我的目標是,所有非/ API網址將rewri tten to index.html for Angularjs處理html5mode的路由。主目錄將加載index.html,但除此之外,我會爲其他每個網址獲得404錯誤。如何通過web.config設置重寫?
我現在所擁有的唯一的控制器是利用航線[Route("api/[controller]")]