468,291 Members | 1,492 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,291 developers. It's quick & easy.

Conditions for HttpContext == null

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?
Nov 19 '05 #1
2 4056
I think one way would be when you are not running within a web site context,
just a normal application.

"Luis Esteban Valencia Muñoz" <le********@avansoft.com> wrote in message
news:uX**************@TK2MSFTNGP09.phx.gbl...
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?

Nov 19 '05 #2
Not in this case. ITs a web application.
"Peter Rilling" <pe***@nospam.rilling.net> escribió en el mensaje
news:%2****************@TK2MSFTNGP15.phx.gbl...
I think one way would be when you are not running within a web site context, just a normal application.

"Luis Esteban Valencia Muñoz" <le********@avansoft.com> wrote in message
news:uX**************@TK2MSFTNGP09.phx.gbl...
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?


Nov 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by John | last post: by
reply views Thread by Aaron Morton | last post: by
2 posts views Thread by Dave | last post: by
3 posts views Thread by Madhur | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.