How to redirect to Index from another controller?

后端 未结 7 1605
滥情空心
滥情空心 2020-12-02 11:06

I have been looking through trying to find some way to redirect to an Index view from another controller.

public ActionResult Index()
{                  


        
7条回答
  •  悲&欢浪女
    2020-12-02 11:35

    You can use local redirect. Following codes are jumping the HomeController's Index page:

    public class SharedController : Controller
        {
            // GET: //
            public IActionResult _Layout(string btnLogout)
            {
                if (btnLogout != null)
                {
                    return LocalRedirect("~/Index");
                }
    
                return View();
            }
    }
    

提交回复
热议问题