Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HttpContext.Error vs HttpContext.Server.GetLastError()

Tags:

asp.net

Are there any practical differences between these two ways of getting an exception for the current asp.net request?

MSDN says HttpContent.Error returns the FIRST error while GetLastError() is evidently the last error, but I can't seem to tell any difference in use.

Which one is the cannon method for error logging?

like image 216
Craig Quillen Avatar asked Apr 11 '09 17:04

Craig Quillen


1 Answers

They're the same:

HttpContext.Error returns the first error.

HttpContext.Server returns an instance of the HttpServerUtility class, which provides convenience wrappers for HttpContext, including

HttpContext.Server.GetLastError(), which returns HttpContext.Error (verified using Reflector).

like image 146
Shog9 Avatar answered Nov 10 '22 01:11

Shog9