其他分享
首页 > 其他分享> > 几种路由跳转的方式

几种路由跳转的方式

作者:互联网

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

 

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


    }

  

标签:Index,return,IActionResult,Route,几种,RouteTest,跳转,public,路由
来源: https://www.cnblogs.com/SHa-Jazy/p/15456045.html