5

I have a themed page whereby the theme is chosen inside a http module.

public void context_PreRequestHandlerExecute(object sender, EventArgs e)
{
    Page p = HttpContext.Current.Handler as Page;

    if (p != null)
    {
        //get theme
        string theme = GetTheme(HttpContext.Current.Request.Url.Host);

        Debug.WriteLine(String.Format("Loading theme {0}", theme));

        //set theme of page
        p.Theme = theme;
    }
}

Now when I request the elmah.axd the following exception is thrown:

Using themed css files requires a header control on the page. (e.g. ).

When I disable the http theme module everything is fine and elmah.axd page is shown. I think this is a small bug inside the ErrorLogPage. The ErrorLogPage should cope with the fact that a theme can be given to the page OR should ignore the given theme at all.

For now I use the workaround:

private const string ELMAH_ERROR_PAGE = "Elmah.ErrorLogPage";

        if (p.GetType().FullName != ELMAH_ERROR_PAGE)
        {
            p.Theme = theme;
        }

Do you have any better ideas or thoughts?

Gr

Martijn

The Netherlands

rick schott
  • 21,012
  • 5
  • 52
  • 81
Martijn B
  • 4,065
  • 2
  • 29
  • 41

1 Answers1

0

A solution to your problem has been answered before:
Exclude certain pages from using a HTTPModule.

You could use an HTTPHandler instead of an HTTPModule. Handlers let you specify a path when you declare them in Web.Config.

<add verb="*" path="/validate/*.aspx" type="Handler,Assembly"/>

If you must use an HTTPModule, you could just check the path of the request and if it's one to be excluded, bypass the validation.

Community
  • 1
  • 1
rick schott
  • 21,012
  • 5
  • 52
  • 81