HttpContext.Server 属性

定义

获取提供用于处理 Web 请求的方法的 HttpServerUtility 对象。Gets the HttpServerUtility object that provides methods used in processing Web requests.

public:
 property System::Web::HttpServerUtility ^ Server { System::Web::HttpServerUtility ^ get(); };
public System.Web.HttpServerUtility Server { get; }
member this.Server : System.Web.HttpServerUtility
Public ReadOnly Property Server As HttpServerUtility

属性值

当前 HTTP 请求的 HttpServerUtilityThe HttpServerUtility for the current HTTP request.

注解

Server 属性提供对 HttpServerUtility 类的属性和方法的编程访问。The Server property provides programmatic access to the properties and methods of the HttpServerUtility class. 由于 ASP.NET 页包含对 System.Web 命名空间(包含 HttpContext 类)的默认引用,因此你可以在不使用对 HttpContext的完全限定类引用的情况下引用 .aspx 页上 HttpContext 的成员。Because ASP.NET pages contain a default reference to the System.Web namespace (which contains the HttpContext class), you can reference the members of HttpContext on an .aspx page without using the fully qualified class reference to HttpContext. 例如,可以使用 Server.CreateObject("MyCOMComponent") 在服务器上创建 COM 对象的实例。For example, you can use Server.CreateObject("MyCOMComponent") to create an instance of a COM object on the server. 但是,如果要从 ASP.NET 代码隐藏模块使用 HttpServerUtility 的成员,则必须在模块中包含对 System.Web 命名空间的引用,并且必须包含对当前活动的请求/响应上下文和中的类的完全限定引用 @no__t要使用的 2However, if you want to use the members of HttpServerUtility from an ASP.NET code-behind module, you must include a reference to the System.Web namespace in the module and a fully qualified reference to both the currently active request/response context and the class in System.Web that you want to use. 例如,在代码隐藏页面中,必须指定 HttpContext.Current.Server.CreateObject("MyCOMComponent")的完全限定名称。For example, in a code-behind page you must specify the fully qualified name HttpContext.Current.Server.CreateObject("MyCOMComponent").

适用于