Page reference in custom IExceptionHandler

G

Guest

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.
 
M

Marc Gravell

Is what you need avaible from HttpRequest.Current? Perhaps on the
..Request?

Alternatively there is the Page.Error event and Page.OnError()
method - you might be able to do something with those?

Marc
 
G

Guest

Thanks mister.

I can access to context like this:

HttpContext.Current.Request

but I haven't page reference :(

Any ideas.
 
M

Marc Gravell

At a push, cast the .Handler to a Page? since the Page is indeed the
handler... not very elegant, but worth a shot

Page page = HttpContext.Current.Handler as Page;
if (page != null) {
// do something
}

Marc
 

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

Top