WebService.Server 属性

定义

获取当前请求的 HttpServerUtilityGets the HttpServerUtility for the current request.

public:
 property System::Web::HttpServerUtility ^ Server { System::Web::HttpServerUtility ^ get(); };
[System.ComponentModel.Browsable(false)]
public System.Web.HttpServerUtility Server { get; }
[<System.ComponentModel.Browsable(false)>]
member this.Server : System.Web.HttpServerUtility
Public ReadOnly Property Server As HttpServerUtility

属性值

HttpServerUtility

一个 HttpServerUtility 对象。An HttpServerUtility object.

属性

示例

以下示例使用属性返回 Web 服务器的计算机名称 ServerThe example below returns the computer name of the Web server using the Server property.

<%@ WebService Language="C#" Class="Util" %>
 
 using System.Web.Services;
 
 public class Util: WebService {
    [ WebMethod(Description="Obtains the Server Computer Name",EnableSession=false)]
    public string GetMachineName() {
       return Server.MachineName;
    }
 }
<%@ WebService Language="VB" Class="Util" %> 

Imports System.Web.Services

Public Class Util
    Inherits WebService
    
    <WebMethod(Description := "Obtains the Computer Machine Name", _
        EnableSession := False)> _
    Public Function GetMachineName() As String
        
        Return Server.MachineName
    End Function
End Class

注解

HttpServerUtility类提供多个可在处理 Web 请求时使用的方法,包括 CreateObject 用于实例化 COM 对象) (。The HttpServerUtility class provides several methods that can be used in the processing of Web requests, including CreateObject (for instantiating COM objects).

适用于

另请参阅