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")

適用於