我怎样才能在ASP.NET MVC的Htt的presponse的参考? [英] How can I get a reference to an HttpResponse in ASP.NET MVC?

查看:79
本文介绍了我怎样才能在ASP.NET MVC的Htt的presponse的参考?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我打电话第​​三方库,需要一个 System.Web.Htt presponse 。我看到我有一个的Htt presponseBase ,而不是的Htt presponse 像Web窗体。

I'm calling a third-party library that takes a System.Web.HttpResponse. I see I have a HttpResponseBase, but not HttpResponse like in web forms.

有没有办法让的Htt presponse ?使用 MVC 3


我试图做到这一点的控制器方法。还纠正外壳。

: I'm trying to do this in a controller method. Also corrected casing.

推荐答案

如果您需要与内搭的非mockable类型的系统进行交互,你可以通过静态属性访问当前HttpContext 的System.Web .HttpContext.Current 。该型Htt presponse只是挂那里通过响应属性。

If you need to interact with systems which take the non-mockable types, you can get access to the current HttpContext via the static property System.Web.HttpContext.Current. The HttpResponse is just hanging off of there via the Response property.

这篇关于我怎样才能在ASP.NET MVC的Htt的presponse的参考?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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