I have just been trying to do a similar thing with Elmah.
My route was set up as follows:
var url = "admin/elmah.axd/{*pathInfo}";
var defaults = new RouteValueDictionary {{"pathInfo", string.Empty}};
var routeHandler = new ElmahHandler();
var route = new Route(url, defaults, routeHandler);
RouteTable.Routes.Add(route);
But I too found that the pathinfo is always empty, so the stylesheet and additional paths didn't work. I managed to achieve my goal using reflection to call the underlying methods in the ErrorLogFactory.
private object InvokeMethod(string name, params object[] args)
{
var dynMethod = typeof(ErrorLogPageFactory).GetMethod(name, BindingFlags.Static | BindingFlags.NonPublic);
return dynMethod.Invoke(null, args );
}
Then my handler looked like this
public class ElmahHandler : ErrorLogPageFactory, IRouteHandler
{
public IHttpHandler GetHttpHandler(RequestContext requestContext)
{
var handler = InvokeMethod("FindHandler", requestContext.RouteData.Values["pathInfo"]) as IHttpHandler;
if (handler == null)
throw new HttpException(404, "Resource not found.");
var num = (int)InvokeMethod("IsAuthorized", context);
if (num != 0 && (num >= 0 || HttpRequestSecurity.IsLocal(context.Request) /*|| SecurityConfiguration.Default.AllowRemoteAccess*/))
{
return handler;
}
//new ManifestResourceHandler("RemoteAccessError.htm", "text/html").ProcessRequest(context);
HttpResponse response = context.Response;
response.Status = "403 Forbidden";
response.End();
return null;
}
}
I had no need to get the ManifestResourceHandler working, so just commented it out, likewise for the allowRemoteAccess setting