Elmah with existing wildcard mapping

已查看 209 次
跳至第一个未读帖子

Sean Chambers

未读,
2008年5月27日 16:14:232008/5/27
收件人 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

未读,
2008年5月27日 17:57:332008/5/27
收件人 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

未读,
2008年5月28日 00:31:032008/5/28
收件人 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

未读,
2008年5月28日 03:40:462008/5/28
收件人 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

未读,
2008年5月28日 07:28:292008/5/28
收件人 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

未读,
2008年5月28日 07:44:512008/5/28
收件人 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

未读,
2008年5月28日 13:05:402008/5/28
收件人 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

未读,
2008年5月28日 13:29:462008/5/28
收件人 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

未读,
2008年5月28日 14:09:502008/5/28
收件人 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
回复全部
回复作者
转发
0 个新帖子