tags:

views:

75

answers:

2

In ASP.NET MVC the convention is that a controller action method should return an ActionResult (or a type derived from ActionResult).

However, you can write a public method that returns pretty much anything and if that method is called (from a browser) the framework will package the return value up as a ContentResult and the browser receives a page of plain text.

This is all very interesting - but would you ever want to do this?

+2  A: 

When you want to render something directly from your controller? e.g. using Response.Write(...); (or using other Response methods).

Hadi Eskandari
+1  A: 

Not returning anything from an action method is essentially not responding to the client's HTTP request with a response.

An empty request might make sense in some cases (HTTP status being enough of a reply), but all web application patterns return something more than this (including, if I understand it correctly, REST: the new state of the entity).

Richard