开发者

why does the controllers action have HttpRequestBase, and the viewpage has HttpRequest?

My methods take HttpRequestBase as arguements, and I am finding it strange as to why the Actions in Controllers h开发者_如何学运维ave access to HttpRequestBase but the view page's have HttpRequest.

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


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜