Page.Context プロパティとは? わかりやすく解説

Page.Context プロパティ

ページ関連付けられている HttpContext オブジェクト取得します

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

Dim value As HttpContext

value = Me.Context
protected public:
virtual property HttpContext^ Context {
    HttpContext^ get () override;
}
/** @property */
protected HttpContext get_Context ()

プロパティ
現在のページ関連付けられた情報格納されている HttpContext オブジェクト

解説解説
使用例使用例

Context プロパティ使用して、HttpContext.AddError メソッド、HttpContext.ClearError メソッド、および HttpContext.AllErrors プロパティアクセスするコード例次に示します。この例では AddError メソッド使用して3 つの独自の例外作成しAllErrors プロパティ使用してそれらの例外配列読み込みます。次に配置先のページにその配列書き込みClearError メソッド使用してすべてのエラーContext プロパティから削除します

Sub Page_Load(Sender As Object,
 e As EventArgs ) 

   Response.Write("<h3>Page.Context Example:</h3>")
      
   ' Add three custom exceptions.
   Context.AddError(new Exception("<font color='red'><h3>New
 Exception #1.</h3>"))
   Context.AddError(new Exception("<font color='red'><h3>New
 Exception #2.</h3>"))
   Context.AddError(new Exception("<font color='red'><h3>New
 Exception #3.</h3>"))
 
   ' Capture all the new Exceptions in an array.
   Dim errs() As Exception = Context.AllErrors
   Dim ex As Exception
   
   For Each ex In errs
         Response.Write("<center><b>"
 + Server.HtmlEncode(ex.ToString()) + "</b></center><br>")
   Next
 
   ' Clear the exceptions so ASP.NET won't handle them.
   Context.ClearError()
End Sub
void Page_Load(Object sender,EventArgs e) 
{
   Response.Write("<h3>Page.Context Example:</h3>");

   // Add three custom exceptions.
   Context.AddError(new Exception("<font color='red'><h3>New
 Exception #1.</h3>"));
   Context.AddError(new Exception("<font color='red'><h3>New
 Exception #2.</h3>"));
   Context.AddError(new Exception("<font color='red'><h3>New
 Exception #3.</h3>"));
 
   // Capture all the new Exceptions in an array.
   Exception[] errs = Context.AllErrors;
 
   foreach (Exception ex in errs)
   {
      Response.Write("<center><b>" + Server.HtmlEncode(ex.ToString())
 + "</b></center><br>"); 
   }
 
   // Clear the exceptions so ASP.NET won't handle them.
   Context.ClearError();
}
void Page_Load(Object sender,System.EventArgs e) 
{
    get_Response().Write("<h3>Page.Context Example:</h3>");

    // Add three custom exceptions.
    get_Context().AddError(new Exception
        ("<font color='red'><h3>New Exception #1.</h3>"));
    get_Context().AddError(new Exception
        ("<font color='red'><h3>New Exception #2.</h3>"));
    get_Context().AddError(new Exception
        ("<font color='red'><h3>New Exception #3.</h3>"));
 
    // Capture all the new Exceptions in an array.
    System.Exception errs[] = get_Context().get_AllErrors();
 
    for (int iCtr=0;iCtr<errs.length;iCtr++)
 {
        System.Exception ex = errs[iCtr];
        get_Response().Write("<center><b>" 
            + get_Server().HtmlEncode(ex.ToString())
            +"</b></center><br>");
    }
    // Clear the exceptions so ASP.NET won't handle them.
    get_Context().ClearError();
}//Page_Load
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



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

辞書ショートカット

すべての辞書の索引

Page.Context プロパティのお隣キーワード
検索ランキング

   

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



Page.Context プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2024 GRAS Group, Inc.RSS