WebContextとは? わかりやすく解説

WebContext クラス

メモ : このクラスは、.NET Framework version 2.0新しく追加されたものです。

現在の Web アプリケーションパス コンテキスト管理します。このクラス継承できません。

名前空間: System.Web.Configuration
アセンブリ: System.Web (system.web.dll 内)
構文構文

Public NotInheritable Class
 WebContext
public sealed class WebContext
public final class WebContext
使用例使用例

WebContext クラス使用する方法次のコード例示します

Imports System
Imports System.Configuration
Imports System.Web
Imports System.Web.Configuration

Namespace Samples.Aspnet.SystemWebConfiguration
  Class UsingWebContext
    Public Shared Sub Main()
      Try
        ' Set the path of the config file.
        Dim configPath As String
 = "/aspnet"

        ' Get the Web application configuration object.
        Dim config As Configuration = _
         WebConfigurationManager.OpenWebConfiguration(configPath)

        ' Get the context.
        Dim webContext As WebContext = config.EvaluationContext.HostingContext

        ' Display title and info.
        Console.WriteLine("ASP.NET WebContext Info")
        Console.WriteLine()

        ' WebContext - Application Level.
        Console.WriteLine("ApplicationLevel: {0}",
 _
          webContext.ApplicationLevel.ToString())
        ' WebContext - Application Path.
        Console.WriteLine("ApplicationPath: {0}",
 _
          webContext.ApplicationPath.ToString())
        ' WebContext - Path.
        Console.WriteLine("Path: {0}", webContext.Path.ToString())
        ' WebContext - Site.
        Console.WriteLine("Site: {0}", webContext.Site.ToString())

      Catch e As Exception
        ' Unknown error.
        Console.WriteLine(e.ToString())
      End Try

      ' Display and wait
      Console.ReadLine()
    End Sub
  End Class
End Namespace

using System;
using System.Configuration;
using System.Web;
using System.Web.Configuration;

namespace WebContextTest01cs
{
  class UsingWebContext
  {
    static void Main(string[]
 args)
    {
      try
      {
        // Set the path of the config file.
        string configPath = "/aspnet";

        // Get the Web application configuration object.
        Configuration config =
          WebConfigurationManager.OpenWebConfiguration(configPath);

        // Get the context.
        WebContext webContext = (WebContext)config.EvaluationContext.HostingContext;

        // Display title.
        Console.WriteLine("ASP.NET WebContext Info");
        Console.WriteLine("");

        // WebContext - Application Level.
        Console.WriteLine("ApplicationLevel: {0}", 
          webContext.ApplicationLevel.ToString());
        // WebContext - Application Path.
        Console.WriteLine("ApplicationPath: {0}", 
          webContext.ApplicationPath.ToString());
        // WebContext - Path.
        Console.WriteLine("Path: {0}", webContext.Path.ToString());
        // WebContext - Site.
        Console.WriteLine("Site: {0}", webContext.Site.ToString());
      }
      catch (Exception ex)
      {
        // Unknown error.
        Console.WriteLine(ex.ToString());
      }

      // Display and wait.
      Console.ReadLine();
    }
  }
}
継承階層継承階層
System.Object
  System.Web.Configuration.WebContext
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
WebContext メンバ
System.Web.Configuration 名前空間

WebContext コンストラクタ

メモ : このコンストラクタは、.NET Framework version 2.0新しく追加されたものです。

WebContext クラス新しインスタンス作成します

名前空間: System.Web.Configuration
アセンブリ: System.Web (system.web.dll 内)
構文構文

Public Sub New ( _
    pathLevel As WebApplicationLevel, _
    site As String, _
    applicationPath As String, _
    path As String, _
    locationSubPath As String _
)
Dim pathLevel As WebApplicationLevel
Dim site As String
Dim applicationPath As String
Dim path As String
Dim locationSubPath As String

Dim instance As New WebContext(pathLevel,
 site, applicationPath, path, locationSubPath)
public WebContext (
    WebApplicationLevel pathLevel,
    string site,
    string applicationPath,
    string path,
    string locationSubPath
)
public:
WebContext (
    WebApplicationLevel pathLevel, 
    String^ site, 
    String^ applicationPath, 
    String^ path, 
    String^ locationSubPath
)
public WebContext (
    WebApplicationLevel pathLevel, 
    String site, 
    String applicationPath, 
    String path, 
    String locationSubPath
)
public function WebContext (
    pathLevel : WebApplicationLevel, 
    site : String, 
    applicationPath : String, 
    path : String, 
    locationSubPath : String
)

パラメータ

pathLevel

WebApplicationLevel オブジェクト

site

Web サイトの名前。

applicationPath

現在の Web アプリケーションルート レベルへの仮想パス

path

現在の構成オブジェクト表している Web.config ファイルへの仮想パス

locationSubPath

現在編集中location 要素パス値。

使用例使用例

WebContext コンストラクタ使用する方法次のコード例示します。このコード例は、WebContext クラストピック取り上げているコード例一部分です。

' Get the context.
Dim webContext As WebContext = config.EvaluationContext.HostingContext
// Get the context.
WebContext webContext = (WebContext)config.EvaluationContext.HostingContext;
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
WebContext クラス
WebContext メンバ
System.Web.Configuration 名前空間

WebContext プロパティ


WebContext メソッド


WebContext メンバ

現在の Web アプリケーションパス コンテキスト管理します。このクラス継承できません。

WebContext データ型公開されるメンバを以下の表に示します


パブリック コンストラクタパブリック コンストラクタ
  名前 説明
パブリック メソッド WebContext WebContext クラス新しインスタンス作成します
パブリック プロパティパブリック プロパティ
パブリック メソッドパブリック メソッド
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

WebContext クラス
System.Web.Configuration 名前空間



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「WebContext」の関連用語

WebContextのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



WebContextのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS