我试图在.net core 2角度项目上设置swashbuckle。
该项目是使用cli的dotnet新角度模板生成的。
我已按照swashbuckle指南向startup.cs类添加了正确的内容但angular2正在处理/ swagger路由并重定向回到home,因为' **'路由。
任何想法如何让swashbuckle使用angular 2 dotnet项目?
答案 0 :(得分:3)
我通过从configure方法中删除fallback spa路由来修复此问题,并根据此github问题创建.MapWhen: https://github.com/aspnet/JavaScriptServices/issues/973
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
/*
routes.MapSpaFallbackRoute(
name: "spa-fallback",
defaults: new { controller = "Home", action = "Index" });
*/
});
app.MapWhen(x => !x.Request.Path.Value.StartsWith("/swagger"), builder =>
{
builder.UseMvc(routes =>
{
routes.MapSpaFallbackRoute(
name: "spa-fallback",
defaults: new { controller = "Home", action = "Index" });
});
});