我如何把一个Htt的prequestBase到的Htt prequest对象吗? [英] How do I convert an HttpRequestBase into an HttpRequest object?

查看:256
本文介绍了我如何把一个Htt的prequestBase到的Htt prequest对象吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的ASP.NET MVC控制器中,我有一个需要的Htt prequest 对象的方法。我所访问是的Htt prequestBase 对象。

inside my ASP.NET MVC controller, I've got a method that requires an HttpRequest object. All I have access to is an HttpRequestBase object.

反正我有可以以某种方式转换呢?

Is there anyway I can somehow convert this?

能有什么/我应该怎么办?

What can/should I do??

推荐答案

这是你的方法,这样你就可以重新编写其采取的Htt prequestBase ?如果没有,你总是可以得到当前的的Htt prequest HttpContext.Current.Htt prequest 传递。不过,我经常换一类中访问的HttpContext像<一提到href=\"http://www.developmentalmadness.com/2009/02/aspnet-removing-systemweb-dependencies.html\">ASP.NET:删除的System.Web依赖更好的单元测试支持。

Is it your method, so you can re-write it to take HttpRequestBase? If not, you can always get the current HttpRequest from HttpContext.Current.HttpRequest to pass on. However, I often wrap access to the HttpContext inside a class like mentioned in ASP.NET: Removing System.Web Dependencies for better unit testing support.

这篇关于我如何把一个Htt的prequestBase到的Htt prequest对象吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆