Page reference in custom IExceptionHandler

Topics: Exception Handling Application Block
Nov 13, 2007 at 9:12 AM
Edited Nov 13, 2007 at 12:25 PM
Hi misters,

I have an application web (asp.net) and I want define custom Handler for exceptionhandling (Enterprise Library)

My custom class..
ConfigurationElementType(typeof(CustomHandlerData))
public class GestorExcepcionesIU : IExceptionHandler


I want to do like this:

Exception IExceptionHandler.HandleException(Exception exception, Guid handlingInstanceId)
{
RegisterStartupScript(@@@PAGE@@@, "jsExcepcionIU", "alert('Error IU: " + exception.Message.Replace("'", " ") + "');");
return exception;
}

How I get reference of Page in the custom handler ?

Any help will be appreciated, and I'll be very grateful. Thanks in advance.
Greetings, regards.

SOLUTION: using HttpContext.Current.Handler property. Important: the value of this property can be null or not Page type (in .ashx for example).

Page page = HttpContext.Current.Handler as Page;
if (page != null)
{
// do something
RegisterStartupScript(page, "jsPoliticaExcepcionIU", "alert('Error Politica IU: " + exception.Message.Replace("'", " ") + "');");
}


--
http://www.alhambra-eidos.es/web2005/index.html
www.kiquenet.net
http://www.setbb.com/putainformatica/viewtopic.php?p=843
www.trabajobasura.com/solusoft
Nov 13, 2007 at 11:06 AM
Hi,

I'm not sure what PAGE is in your context. Is it an instance, or a type?
Anyway, you can only get data that is either global or included in your exception. What's the case in your scenario?

Fernando
Apr 26, 2010 at 7:54 PM

Using HttpContext.Current.Handler as Page;