Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Application level exception handling
Message
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
00833443
Message ID:
00833919
Vues:
29
>Rick mentioned that the Application_Error method is Autowired in one of his posts. I may have misled you earlier by saying that you have to hook into that event. If you still have the Error += new EventHandler... in your global.asax, remove it.

Yup. Already did that.

> I would also comment out the redirect and just write a message out instead

Woa! Now we're getting somewhere! But it's still a little strange.

Took your suggestion above (and implemented Rick's use of InnerException):
string ErrorDescription = Server.GetLastError().InnerException.ToString();
string RedirectString = "Error.aspx?ErrorDescription=" + ErrorDescription;
// Response.Redirect(RedirectString);
Response.Write(RedirectString);
Server.ClearError();
And now the Response.Write is apparently getting executed, because the contents of the string are being written to the current page, but this is occurring as soon as I "step into" to get past the breakpoint on the first line. I never see the assignment of the RedirectString string variable, nor do I see the call to Response.Write(). Could be just something wierd about tracing code in the Global.ASAX.CS.

Just for fun, I did a Response.Redirect() at the same point in the app that I'm throwing the error, and the Redirect() method and Error.aspx seem to be working fine, so I don't know why the Redirect() would trigger an error in the Application_Error() method.

I also tried substituting (tested) code (see below) to write out the error information to a text file instead of the Response.Write(), and the that calls the code-behind page in which the error is being thrown is blanked, but the text file is not being generated.
string ErrorDescription = Server.GetLastError().InnerException.ToString();
Server.ClearError();
FileStream oFs = new FileStream("ErrorLog.Txt",
    FileMode.Append,FileAccess.Write);
StreamWriter oWriter = new StreamWriter(oFs);	
oWriter.Write(ErrorDescription);	
oWriter.Flush();	
oWriter.Close();	
oFs.Close();			
>>-Steve->>

Steve Sawyer
Geeks and Gurus, Inc.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform