System.Web.HttpContext.Current vs. ControllerContext.HttpContext (almost the same)
2012-09-04 15:40
411 查看
Refer to http://stackoverflow.com/questions/785413/difference-between-httpcontext-current-and-controller-context-in-mvc-asp-net
The context provided by the controller (not the static HttpContext.Current) is mockable. If you're interested in unit-testing your code, it's generally far easier to create a mock ControllerContext and set it on the Controller than it is to go through HttpContext.Current. Otherwise ControllerContext.HttpContext points to the same data as HttpContext.Current.
The context provided by the controller (not the static HttpContext.Current) is mockable. If you're interested in unit-testing your code, it's generally far easier to create a mock ControllerContext and set it on the Controller than it is to go through HttpContext.Current. Otherwise ControllerContext.HttpContext points to the same data as HttpContext.Current.
相关文章推荐
- System.Web.HttpContext.Current.Session为NULL值的问题?
- 线程Thread调用时System.Web.HttpContext.Current为NULL
- System.Web.HttpContext.Current.Session获取值出错
- System.Web.HttpContext.Current.Session获取值出错
- 线程调用方法 System.Web.HttpContext.Current.Server.MapPath()
- System.Web.HttpContext.Current 跟踪分析
- System.Web.HttpContext.Current.Session获取值出错
- 慎用System.Web.HttpContext.Current
- System.Web.HttpContext.Current.Server.MapPath("~/upload/SH") 未将对象引用设置为实例对象
- System.Web.HttpContext.Current.Cache 与System.Web.HttpRuntime.Cache
- System.Web.HttpContext.Current.Cache和System.Web.HttpRuntime.Cache有什么区别?
- HttpContext为null new HttpContextWrapper(System.Web.HttpContext.Current)
- System.Web.HttpContext.Current.Server.MapPath()
- System.Web.HttpContext.Current.Cache和System.Web.HttpRuntime.Cache有什么区别?
- 为什么获取的System.Web.HttpContext.Current值为null,HttpContext对象为null时如何获取程序(站点)的根目录
- System.Web.HttpContext.Current.Session为NULL值的问题?
- System.Web.HttpContext.Current.Session NullReference错误
- asp.net后台导出excel的方法:使用System.Web.HttpContext.Current.Response导出excel
- System.Web.HttpContext.Current是什么
- .net System.Web.HttpContext.Current.Session 获取值出错(在Page继承类的构造函数中出错)