通过


HttpContext.Server 属性

定义

HttpServerUtility获取提供处理 Web 请求的方法的对象。

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 请求的 HttpServerUtility

注解

Server 属性提供对类的属性和方法的 HttpServerUtility 编程访问。 由于 ASP.NET 页包含对 System.Web 命名空间的默认引用(其中包含 HttpContext 类),因此可以在.aspx页上引用成员 HttpContext ,而无需使用对该类的完全限定的类引用 HttpContext。 例如,可用于 Server.CreateObject("MyCOMComponent") 在服务器上创建 COM 对象的实例。 但是,如果要使用来自 ASP.NET 代码隐藏模块的成员 HttpServerUtility ,则必须在模块中包含对命名空间的引用,以及对 System.Web 当前活动请求/响应上下文和要使用的类 System.Web 的完全限定引用。 例如,在代码隐藏页中,必须指定完全限定的名称 HttpContext.Current.Server.CreateObject("MyCOMComponent")

适用于