Conditions for HttpContext == null

  • Thread starter Luis Esteban Valencia Muñoz
  • Start date
L

Luis Esteban Valencia Muñoz

I have a 2 base classes that do error handling -- one for pages
(System.Web.UI.Page) and one for applications (System.Web.HttpApplication,
Global.asax uses it).

Are there any situations in either of these error handlers where
HttpContext.Current would be null?

Page Error Handler

public class PageBase : System.Web.UI.Page {
protected override void OnError(EventArgs e) {
HttpContext ctx = HttpContext.Current;
if (ctx == null) {
// is this even possible?
}
}

Application Error Handler

public class GlobalBase : System.Web.HttpApplication {
protected void Application_Error(Object sender, EventArgs e) {
HttpContext ctx = HttpContext.Current;
if (ctx == null) {
// how about this situation? is this possible?
}
}
}

If the context could be null in either situation, then I wouldn't be able to
get the exception information anyway. Should I just log it and return?
 
P

Peter Rilling

I think one way would be when you are not running within a web site context,
just a normal application.
 
L

Luis Esteban Valencia Muñoz

Not in this case. ITs a web application.
Peter Rilling said:
I think one way would be when you are not running within a web site context,
just a normal application.

able
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top