Return 307 Temporary Redirect in ASP.NET MVC

后端 未结 3 1555
深忆病人
深忆病人 2020-12-19 01:49

Is it possible to return a 307 Temporary Redirect from a controller in ASP.NET MVC?

I sometimes need to re-POST the values submitt

3条回答
  •  死守一世寂寞
    2020-12-19 01:56

    To return a 307 redirect result from an MVC action, use the following:

    public ActionResult Action()
    {
        string url = GetRedirectUrl()
        HttpContext.Response.AddHeader("Location", url);
        return new HttpStatusCodeResult(307);
    }
    

提交回复
热议问题