Return http 204 "no content" to client in ASP.NET MVC2

Posted by Jeremy Raymond on Stack Overflow See other posts from Stack Overflow or by Jeremy Raymond
Published on 2010-12-22T20:50:21Z Indexed on 2010/12/22 20:54 UTC
Read the original article Hit count: 198

Filed under:
|

In an ASP.net MVC 2 app that I have I want to return a 204 No Content response to a post operation. Current my controller method has a void return type, but this sends back a response to the client as 200 OK with a Content-Length header set to 0. How can I make the response into a 204?

[HttpPost]
public void DoSomething(string param)
{
    // do some operation with param

    // now I wish to return a 204 no content response to the user 
    // instead of the 200 OK response
}

© Stack Overflow or respective owner

Related posts about asp.net-mvc-2

Related posts about httpresponse