将请求从www.mysite.com重定向到www.mysite.com/swagger的正确方法是什么? 我设置了一个索引控制器装饰路线(“”),它的工作原理,但看起来像一个Kludge.我假设应该有一种方法在Startup.cs中的MV
我设置了一个索引控制器装饰路线(“”),它的工作原理,但看起来像一个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");
}
}
请尝试以下重定向规则:
var option = new RewriteOptions();
option.AddRedirect("^$", "swagger");
app.UseRewriter(option);
