Page.Context プロパティ
アセンブリ: System.Web (system.web.dll 内)
![構文](http://weblio.hs.llnwd.net/e7/img/dict/msdnc/minus.gif)
![解説](http://weblio.hs.llnwd.net/e7/img/dict/msdnc/minus.gif)
![使用例](http://weblio.hs.llnwd.net/e7/img/dict/msdnc/minus.gif)
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
![プラットフォーム](http://weblio.hs.llnwd.net/e7/img/dict/msdnc/minus.gif)
Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
![バージョン情報](http://weblio.hs.llnwd.net/e7/img/dict/msdnc/minus.gif)
![参照](http://weblio.hs.llnwd.net/e7/img/dict/msdnc/minus.gif)
- Page.Context プロパティのページへのリンク