Sunday, August 1, 2010

Request and Response in ASP.NET MVC

The Controller class exposes Request and Response properties that can be accessed in an action method. These properties have the same semantics as the HttpRequest and HttpResponse objects that are already a part of ASP.NET.

However, the Request and Response objects of the Controller class accept objects that implement the HttpRequestBase and HttpResponseBase abstract classes instead of being sealed classes.

Sample code

public void Detail()
{
int id = Convert.ToInt32(Request["id"]);
}