Hello Eric,
As for the HttpException, did you manually create an HttpExcetion instance
and throw it in your page code?
Based on my research, HttpException.GetHtmlErrorMessage method does rely on
a certain ErrorFormatter to generate the HtmlErrorMessage. Also, it uses an
internal method "SetFormatter" to assign a formatter, based on my
inspection through the reflector, not any discretionary instance of such
HttpException instance will be assigned a proper ErrorFormatter. One of the
means to set the ErrorFormatter is create a HttpUnhandledException instance
to wrapper the HttpException and in the HttpUnhandledException's
constructor, it will assign a "UnhandledErrorFormatter". e.g.
===================
public partial class Errorhandle_ErrorHandle : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnRaise_Click(object sender, EventArgs e)
{
try
{
GetError();
}
catch (HttpException httpexp)
{
Response.Write("<br/>error<br/>: " +
httpexp.GetHtmlErrorMessage());
}
}
protected void GetError()
{
HttpException httpexp = new HttpException("test httpexp........");
HttpUnhandledException ux = new HttpUnhandledException("wrapper
exp", httpexp);
throw ux;
}
}
========================
BTW, is there any paricular requirement in your scenario that you need to
use the system generated html error message instead of using your own
custom exception and own error message?
Please feel free to post here if there is any other concerns or anything we
can help.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.