How to simulate Server.Transfer in ASP.NET MVC?

后端 未结 14 1413
死守一世寂寞
死守一世寂寞 2020-11-22 12:00

In ASP.NET MVC you can return a redirect ActionResult quite easily :

 return RedirectToAction(\"Index\");

 or

 return RedirectToRoute(new { controller = \"         


        
14条回答
  •  名媛妹妹
    2020-11-22 12:26

    Rather than simulate a server transfer, MVC is still capable of actually doing a Server.TransferRequest:

    public ActionResult Whatever()
    {
        string url = //...
        Request.RequestContext.HttpContext.Server.TransferRequest(url);
        return Content("success");//Doesn't actually get returned
    }
    

提交回复
热议问题