How to return a 200 HTTP Status Code from ASP.NET MVC 3 controller

前端 未结 5 1496
刺人心
刺人心 2020-12-12 11:48

I am writing an application that is accepting POST data from a third party service.

When this data is POSTed I must return a 200 HTTP Status Code.

How can I

5条回答
  •  抹茶落季
    2020-12-12 12:39

    In your controller you'd return an HttpStatusCodeResult like this...

    [HttpPost]
    public ActionResult SomeMethod(...your method parameters go here...)
    {
       // todo: put your processing code here
    
       //If not using MVC5
       return new HttpStatusCodeResult(200);
    
       //If using MVC5
       return new HttpStatusCodeResult(HttpStatusCode.OK);  // OK = 200
    }
    

提交回复
热议问题