我如何可以访问ASP.NET MVC控制器获取HttpServerUtility实例? [英] How can I access the HttpServerUtility instance in ASP.NET MVC controller?

查看:351
本文介绍了我如何可以访问ASP.NET MVC控制器获取HttpServerUtility实例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何访问获取HttpServerUtility比如在ASP.NET MVC控制器?

How can I access the HttpServerUtility instance in ASP.NET MVC controller?

推荐答案

this.httpContext.Server是一个参考的HttpServerUtilityBase,抽象类包装这就是System.Web.Abstractions DLL的一部分。你也可以这样做:

"this.httpContext.Server" is a reference to HttpServerUtilityBase, the abstract class wrapper that's a part of the System.Web.Abstractions DLL. You can also do:

HttpContext.Current.Server

要直接访问老派的方式。您也可以通过做使用包装得到的基类的一个实例如下:

To directly access the "old-school" way. Also you can get an instance of the base class using the wrapper by doing the following:

new HttpServerUtilityWrapper(HttpContext.Current.Server)

包装类,从的HttpServerUtilityBase

The wrapper class inherits from httpServerUtilityBase

这篇关于我如何可以访问ASP.NET MVC控制器获取HttpServerUtility实例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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