【发布时间】:2017-07-03 14:54:27
【问题描述】:
将请求从 www.mysite.com 重定向到 www.mysite.com/swagger 的正确方法是什么?
我设置了一个用 Route("") 装饰的索引控制器,它可以工作,但看起来像一个 Kludge。我认为应该有一种方法可以在 Startup.cs 的 MVC 路由中指定它,我就是想不通。
// kludge code, how do I do this in app.UseMvc(route => route.MapRoute...
[ApiExplorerSettings(IgnoreApi = true)]
[Route("")]
public class IndexController : Controller
{
public ActionResult Index()
{
return Redirect("/swagger");
}
}
【问题讨论】:
-
是上面帖子中提到的代码,对你有用吗?因为它在我的情况下不起作用。
-
@VaultBoy14 我需要更多详细信息 1) 使用的是 Asp.Net Core (.NET Core) 还是 Asp.Net (.Net Framework)? 2) 你安装了什么 Swashbuckle (Swagger) NuGet 包?
标签: asp.net-core asp.net-core-mvc swagger swashbuckle