Converting System.Exception to System.Web.HttpCompileException in global.asax Application_Error - .NET 1.1

Hello.  I am capturing an exception in the above event handler using Server.GetLastError().  I would like to access the Results and SourceCode properties of an inner exception of type System.Web.HttpCompileException, but cannot do so, and am unable to implicitly convert a general exception to System.Web.HttpCompileException.  Any ideas?

 Thank you in advance,

Chris.

0
BIDeveloper
5/5/2008 4:00:00 PM
📁 asp.net.getting-started
📃 91979 articles.
⭐ 4 followers.

💬 1 Replies
👁️‍🗨️ 1291 Views

Solved my own problem via the following code.  Feeling kind of embarrassed over the simple fix. 

if (lastErr.InnerException.GetType().ToString() == "System.Web.HttpCompileException")
{
	compileErr = lastErr.InnerException as HttpCompileException;

	errMsg += "Results: " + compileErr.Results + "<BR>";
	errMsg += "Source Code: " + compileErr.SourceCode + "<BR>";
}
 
0
BIDeveloper
5/5/2008 6:05:00 PM
Reply:

Similar Posts: