这里记录下来,供自己看。
[Route("[controller]")] public class RouteTestController : Controller { [Route("/RouteTest/Index")] // 没有Route时,http://localhost:14206/RouteTest 默认访问这个方法: public IActionResult Index() { return View(); } [Route("/RouteTest/RedirectURl")] public IActionResult RedirectURl() { return Redirect("https://www.baidu.com/"); } [Route("/RouteTest/LocalRedirect")] public IActionResult LocalRedirect() { return LocalRedirect("/RouteTest/Index"); } [Route("/RouteTest/RedirectSomeAction")] public IActionResult RedirectSomeAction() { return Redirect("/NLog/Test"); } //[Route("/RouteTest/RedirectAppointAction")] //public IActionResult RedirectAppointAction() //{ // return RedirectToRoute("/RouteTest/Index", new { action = "Index", Controller = "RouteTest" }); //} }