问题描述
在我的 Asp.net Core (MVC) 应用程序中安装 Swashbuckle.AspNetCore 后,默认路由被index.html"页面覆盖.
After installing the Swashbuckle.AspNetCore in my Asp.net Core (MVC) application the default route is override with "index.html" page.
我曾经使用~/"的地方现在将我的应用程序重定向到~/index.html"而不是默认的 MVC 路由.
Where ever I used "~/" now is redirecting my application to "~/index.html" instead of default MVC route.
我该如何解决这个问题?
How i can fix this?
推荐答案
我在将 swagger 的路由前缀设置为 root 后遇到这个问题,即
I had encountered this issue after setting the route prefix of swagger to root i.e.
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "LMW Valuer API V1");
c.RoutePrefix = string.Empty;
});
即使删除了路由前缀,我仍然被重定向到 index.html.
Even after removing the route prefix, I was still being redirected to index.html.
为了解决我的问题,我必须清除我网站的浏览器缓存.
To solve my issue I has to clear the browser cache for my site.
希望这会有所帮助.
这篇关于Aspnet core 2.2 默认路由改为“~/index.html";安装 Swashbuckle.AspNetCore 包后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!