次の方法で共有


WebService.Server プロパティ

現在の要求に対する HttpServerUtility を取得します。

Public ReadOnly Property Server As HttpServerUtility
[C#]
public HttpServerUtility Server {get;}
[C++]
public: __property HttpServerUtility* get_Server();
[JScript]
public function get Server() : HttpServerUtility;

プロパティ値

HttpServerUtility オブジェクト。

解説

HttpServerUtility クラスは、COM オブジェクトのインスタンス化に使用する CreateObject など、Web 要求を処理する際に使用できるメソッドをいくつか提供します。

使用例

[Visual Basic, C#] Server プロパティを使用して、Web サーバーのコンピュータ名を返す例を次に示します。

 
<%@ 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
    

[C#] 
<%@ 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;
    }
 }
    

[C++, JScript] C++ および JScript のサンプルはありません。Visual Basic および C# のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

参照

WebService クラス | WebService メンバ | System.Web.Services 名前空間 | HttpServerUtility | CreateObject