Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You can do exactly that and override ElmahController. In fact <a href="http://www.beletsky.net/2011/03/integrating-elmah-to-aspnet-mvc-in.html" rel="nofollow">Alexander Beletsky</a> has already provided a <a href="https://www.nuget.org/packages/Elmah.MVC" rel="nofollow">nuget package</a> for just that called <a href="https://www.nuget.org/packages/Elmah.MVC" rel="nofollow">Elmah.Mvc</a>.</p> <p>Once you've created your own ElmahController then you can apply whatever authorization you like to it. In my application I have a base authorized controler which applies it. You just need to configure your routes and return an Elmah result, it's all well documented on his site.</p> <p>UPDATE: been a while since I looked at this but I've my own controller, inspired by above but not actually using it.</p> <pre><code>[Authorize] public class ElmahController : BaseAuthorizedController { public ActionResult Index(string type) { return new ElmahResult(type); } } </code></pre> <p>where the result is this</p> <pre><code>using System; using System.Web; using System.Web.Mvc; namespace Epic.Mvc.Mvc.ActionResults { public class ElmahResult : ActionResult { private readonly string _resouceType; public ElmahResult(string resouceType) { _resouceType = resouceType; } public override void ExecuteResult(ControllerContext context) { var factory = new Elmah.ErrorLogPageFactory(); if (!string.IsNullOrEmpty(_resouceType)) { var pathInfo = "/" + _resouceType; context.HttpContext.RewritePath(FilePath(context), pathInfo, context.HttpContext.Request.QueryString.ToString()); } var currentApplication = (HttpApplication)context.HttpContext.GetService(typeof(HttpApplication)); if (currentApplication == null) return; var currentContext = currentApplication.Context; var httpHandler = factory.GetHandler(currentContext, null, null, null); if (httpHandler is IHttpAsyncHandler) { var asyncHttpHandler = (IHttpAsyncHandler)httpHandler; asyncHttpHandler.BeginProcessRequest(currentContext, r =&gt; { }, null); } else { httpHandler.ProcessRequest(currentContext); } } private string FilePath(ControllerContext context) { return _resouceType != "stylesheet" ? context.HttpContext.Request.Path.Replace(String.Format("/{0}", _resouceType), string.Empty) : context.HttpContext.Request.Path; } } } </code></pre> <p>and I have two routes (the second very optional)</p> <pre><code>routes.MapRoute("ElmahHandler", "elmah/{type}", new { action = "Index", controller = "Elmah", type = UrlParameter.Optional }); routes.MapRoute("ElmahHandlerShortHand", "errors/{type}", new { action = "Index", controller = "Elmah", type = UrlParameter.Optional }); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload