我希望除了/api/*
之外的所有請求都擊中wwwroot文件夾中的默認文件,因爲我正在運行一個Spa!所有ASPNET核心路由去DefaultFiles
我有這樣的配置:
app.UseIdentityServer();
app.UseIdentityServerAuthentication(new IdentityServerAuthenticationOptions
{
Authority = identityServerAppOptions.Value.Authority,
RequireHttpsMetadata = false,
ApiName = "all",
});
app.UseDefaultFiles(new DefaultFilesOptions
{
DefaultFileNames = new List<string> { "index.html" }
});
app.UseStaticFiles(new StaticFileOptions
{
OnPrepareResponse = ctx =>
{
ctx.Context.Response.Headers.Append("Cache-Control", "no-cache");
}
});
app.UseMvc(routes => routes.MapRoute(
name: "default",
template: "api/{controller=Details}/{id?}"));
但路線/Account/Login
不從靜態文件位置的默認文件。
我試過在靜態文件選項上使用RequestPath
,但這聽起來不像是正確的事情!
你有磁盤上的wwwroot/Account/Login/index.html文件嗎? –
沒有所有的文件都在'wwwroot'中,用於服務SPA應用程序 –