Elmah with existing wildcard mapping

213 views
Skip to first unread message

Sean Chambers

unread,
May 27, 2008, 4:14:23 PM5/27/08
to ELMAH
Hello,

I am currently using Castle MonoRail with a wildcard mapping so
everything is routed to asp.net so that I can use the routing features
available in monorail. This seems to be causing a problem with ELMAH
as the elmah.axd/stylesheet, elmah/rss. Which are all being shown as
404 errors since everything is being mapping to aspnet_isapi.dll

I tried placing the elmah.axd httpHandler before my handler for
MonoRail, but it didn't seem to make a difference.

Has anyone else tried to use ELMAH with Castle MonoRail + Wildcard
Mapping? I would be interested in how to get this to work.

Thank you!

Sean

Atif Aziz

unread,
May 27, 2008, 5:57:33 PM5/27/08
to el...@googlegroups.com
Hi Sean,

If I am not wrong, this is a known issue. When you do wildcard mapping, the PATH_INFO, which ELMAH's handler factory uses to decided which handler to serve, gets calculate slightly differently. There is a workaround, which involves explicitly registering all paths, such that ASP.NET resolves them back to ELMAH once more. For starters, try to see if adding the following entry to the <httpHandlers> section helps with restoring the RSS feed:

<add verb="POST,GET,HEAD" path="elmah.axd/rss" type="Elmah.ErrorRssHandler, Elmah" />

If you manage to get the RSS feed back then we're in the right direction and then we can work through restoring other areas (like the style sheet).

- Atif

Sean Chambers

unread,
May 28, 2008, 12:31:03 AM5/28/08
to ELMAH
Hello,

That did get the RSS feed working. I tried to do the Stylesheet as
well but wasn't sure of the Handler class that the stylesheet uses and
was not in front of my dev machine at the moment.

What other services would I have to map directly back to elmah?

Thanks for your help!

Sean
> Sean- Hide quoted text -
>
> - Show quoted text -

Atif Aziz

unread,
May 28, 2008, 3:40:46 AM5/28/08
to el...@googlegroups.com
> That did get the RSS feed working.

Great, so you need to add the following entries to get the rest (except the style sheet but more on that later) up and running as well.

<add verb="GET,HEAD,POST" path="elmah.axd/detail" type="Elmah.ErrorDetailPage, Elmah" />
<add verb="GET,HEAD,POST" path="elmah.axd/html" type="Elmah.ErrorHtmlPage, Elmah" />
<add verb="GET,HEAD,POST" path="elmah.axd/rss" type="Elmah.ErrorRssHandler, Elmah" />
<add verb="GET,HEAD,POST" path="elmah.axd/digestrss" type="Elmah.ErrorDigestRssHandler, Elmah" />
<add verb="GET,HEAD,POST" path="elmah.axd/xml" type="Elmah.ErrorXmlHandler, Elmah" />
<add verb="GET,HEAD,POST" path="elmah.axd/download" type="Elmah.ErrorLogDownloadHandler, Elmah" />
<add verb="GET,HEAD,POST" path="elmah.axd/about" type="Elmah.AboutPage, Elmah" />

If the formatting of the above entries gets corrupted between various mail and web systems then I've also placed them in a file attached to this post.

The above entries are basically doing the work of ErrorLogPageFactory, but more explicitly. Some things don't map so well, however, and the style sheet is one of them. The reason for this is that there is no direct handler you can register for it. Instead, what you'll need to do is place the style sheet directly on disk at the expected path. For example, if the style sheet is being looked for in elmah.axd/stylesheet, then you'll need to create a directory called elmah.axd and place a file in there called "stylesheet" (without any extension to the file name). In fact, best thing is to copy the ErrorLog.css (see http://elmah.googlecode.com/svn/trunk/src/Elmah/ErrorLog.css) file and rename it there.

Hope this helps,

handlers.config

Sean Chambers

unread,
May 28, 2008, 7:28:29 AM5/28/08
to ELMAH
beautiful!!

That worked perfectly. I knew it had to be an easy fix. I played with
my routing configuration in Castle for awhile but couldn't get it to
work, so I figured there would be a way to explicitly map those
services.

Thank you very much! Very nice tool! I was using an Exception handler
in my codebase, but this is mainly for logging via log4net, so this
tool gives a nice gui to browsing the errors.

Thanks again man! I appreciate it

Sean

On May 28, 3:40 am, Atif Aziz <Atif.A...@skybow.com> wrote:
> > That did get the RSS feed working.
>
> Great, so you need to add the following entries to get the rest (except the style sheet but more on that later) up and running as well.
>
> <add verb="GET,HEAD,POST" path="elmah.axd/detail" type="Elmah.ErrorDetailPage, Elmah" />
> <add verb="GET,HEAD,POST" path="elmah.axd/html" type="Elmah.ErrorHtmlPage, Elmah" />
> <add verb="GET,HEAD,POST" path="elmah.axd/rss" type="Elmah.ErrorRssHandler, Elmah" />
> <add verb="GET,HEAD,POST" path="elmah.axd/digestrss" type="Elmah.ErrorDigestRssHandler, Elmah" />
> <add verb="GET,HEAD,POST" path="elmah.axd/xml" type="Elmah.ErrorXmlHandler, Elmah" />
> <add verb="GET,HEAD,POST" path="elmah.axd/download" type="Elmah.ErrorLogDownloadHandler, Elmah" />
> <add verb="GET,HEAD,POST" path="elmah.axd/about" type="Elmah.AboutPage, Elmah" />
>
> If the formatting of the above entries gets corrupted between various mail and web systems then I've also placed them in a file attached to this post.
>
> The above entries are basically doing the work of ErrorLogPageFactory, but more explicitly. Some things don't map so well, however, and the style sheet is one of them. The reason for this is that there is no direct handler you can register for it. Instead, what you'll need to do is place the style sheet directly on disk at the expected path. For example, if the style sheet is being looked for in elmah.axd/stylesheet, then you'll need to create a directory called elmah.axd and place a file in there called "stylesheet" (without any extension to the file name). In fact, best thing is to copy the ErrorLog.css (seehttp://elmah.googlecode.com/svn/trunk/src/Elmah/ErrorLog.css) file and rename it there.
>  handlers.config
> 1KDownload- Hide quoted text -

Sean Chambers

unread,
May 28, 2008, 7:44:51 AM5/28/08
to ELMAH
One more thing, Elmah seems to also be looking for a stylesheet under
each resource. I keep getting File not Found exceptions popping up as
I am browsing through the error log.

elmah.axd\about\stylesheet

elmah.axd\digestrss\detail


Those are the only two i've seen so far. I guess the easiest thing
would be to just add those directories under the elmah.axd directory
and manually copy the stylesheet file to the directories.
> > - Show quoted text -- Hide quoted text -

James_2JS

unread,
May 28, 2008, 1:05:40 PM5/28/08
to ELMAH
Hi!

Is this the IIS 5.x problem as described in this post??
http://forums.asp.net/t/1113541.aspx
If so, does this do the trick?? NB pilfered from the post!!!

To solve this problem, create a file called
IIS5XWildCardExtensionFix.cs and place it in your App_Code folder:

using System;
using System.Web;

public class IIS5XWildCardExtensionFix : IHttpModule
{
public IIS5XWildCardExtensionFix() { }

public void Dispose() { }

public void Init(HttpApplication context)
{
context.BeginRequest += new EventHandler(OnBeginRequest);
}

private void OnBeginRequest(object sender, EventArgs e)
{
HttpApplication app = sender as HttpApplication;
HttpContext context = app.Context;
string path = context.Request.Path;
int elmahaxd = path.IndexOf("elmah.axd/",
StringComparison.OrdinalIgnoreCase);
if (elmahaxd >= 0)
context.RewritePath(
path.Substring(0, elmahaxd + 9),
path.Substring(elmahaxd + 9),
context.Request.QueryString.ToString());
}
}
Add the following line to in your web.config file in the HttpModules
tag:

<add name="IIS5XWildCardExtensionFix"
type="IIS5XWildCardExtensionFix" />

Cheers,

James

Sean Chambers

unread,
May 28, 2008, 1:29:46 PM5/28/08
to ELMAH
this problem is only on my dev machine which is IIS5, the problem
doesnt exist in QA and production which are IIS6 environments.

It doesn't need to work correctly on my local dev machine so It should
be ok. Thanks for the info!

Sean

On May 28, 1:05 pm, James_2JS <jamesdrisc...@btinternet.com> wrote:
> Hi!
>
> Is this the IIS 5.x problem as described in this post??http://forums.asp.net/t/1113541.aspx

James_2JS

unread,
May 28, 2008, 2:09:50 PM5/28/08
to ELMAH
Hi Sean,

> this problem is only on my dev machine which is IIS5, the problem
> doesnt exist in QA and production which are IIS6 environments.

Interesting... so it sounds like the solution above might work...
Could you give it a try and let us know how you get on so that we've
got a solution for others??!

Many thanks,

James
Reply all
Reply to author
Forward
0 new messages