Redirect from asp.net web api post action

前端 未结 4 933
深忆病人
深忆病人 2020-11-27 14:05

I\'m very new to ASP.NET 4.0 Web API. Can we redirect to another URL at the end of the POST action?, something like ... Response.Redirect(url)

Actually

4条回答
  •  时光说笑
    2020-11-27 14:21

    Sure:

    public HttpResponseMessage Post()
    {
        // ... do the job
    
        // now redirect
        var response = Request.CreateResponse(HttpStatusCode.Moved);
        response.Headers.Location = new Uri("http://www.abcmvc.com");
        return response;
    }
    

提交回复
热议问题