几种路由跳转的方式

这里记录下来,供自己看。

 

 [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" });
        //}


    }

  

上一篇:策略路由 policy routing rt_tables


下一篇:四、vue脚手架routes的配置