在我的 ASP.NET MVC Controller 中,我有一个需要 HttpRequest
对象的方法。我所能访问的只是一个 HttpRequestBase
对象。
我可以以某种方式转换它吗?
我可以/应该做什么?
最佳答案
您应该始终在应用程序中使用 HttpRequestBase 和 HttpResponseBase,而不是无法测试的具体版本(没有 typemock 或其他一些魔法)。
只需使用 HttpRequestWrapper要转换的类,如下所示。
var httpRequestBase = new HttpRequestWrapper(Context.Request);
关于asp.net-mvc - 如何将 HttpRequestBase 转换为 HttpRequest 对象?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1452522/