views:

158

answers:

2

My methods take HttpRequestBase as arguements, and I am finding it strange as to why the Actions in Controllers have access to HttpRequestBase but the view page's have HttpRequest.

Is there a reason for this or just something that was not thought through?

+2  A: 

View pages have access to the MVC HttpContext through ViewContext.HttpContext, which is an HttpContextBase.

The seemingly dual access is just due to the way ASP.Net works. When you look at Request.HttpContext, this is the ASP.Net pipeline's injection of the original HttpContext. This is accessible in any HttpHandler, whether it's an MVC controller or view, or a WebForms page or ashx.

womp
+1  A: 

ViewPage inherits from System.Web.UI.Page and I'm pretty positive all of the HttpRequest members are inherited from that:

http://msdn.microsoft.com/en-us/library/dd504962.aspx

jfar