剑轩

.net core设置swagger为起始页

电脑版发表于:2019/10/17 10:11


方法一:使用中间件来设置

app.Use(next => async context =>
{
    if (context.Request.Path == "/")
    {
        context.Response.Redirect("/swagger");
        return;
    }
    await next(context);
});

方法二:自定义路由


方法三:swagger配置


方法很多种比如:
用中间件自定义路由,过滤器中跳转(直接一个重定向即可),控制器中跳转(一样直接一个重定向即可)),自定义路由都可以(起始页匹配的都是空模板,然后进行跳转即可)

关于TNBLOG
TNBLOG,技术分享。技术交流:群号677373950
ICP备案 :渝ICP备18016597号-1
App store Android
精彩评论
{{item.replyName}}
{{item.content}}
{{item.time}}
{{subpj.replyName}}
@{{subpj.beReplyName}}{{subpj.content}}
{{subpj.time}}
猜你喜欢