Skip to content

Mellbourn/elmah.mvc

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

65 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ELMAH.MVC

For painless integration of ELMAH into ASP.NET MVC application.

What's changed in 2.0 version?

For details, please follow that blog post - ELMAH.MVC v.2.0 - Release Candidate

What's the goal?

With ELMAH.MVC you got nice and clear MVC style routing to ELMAH error page. ELMAH can be accessed by:

http://yourapp.com/elmah

By doing that, you can apply any authorization strategies or routes. In short, no more

http://yourapp.com/elmah.axd

That could be used for ASP.NET session hijacking with Google and ELMAH.

How to use in my application?

Easy. Install ELMAH by NuGet, in package console

Install-Package Elmah.MVC

For further ELMAH configuration please check the documentation.

Should I use HandleErrorAttribute?

If you tried to use ELMAH in ASP.NET MVC, you are probably implemented your own HandleErrorAttribute, as it's shown in this example. You no longer need to apply this custom code with Elmah.MVC. As soon you installed package, so can safely remove your HandleError attribute, since it's already included into package.

Will exceptions being logged in "customError='On'" mode?

Yes, even in you configured application to use custom error pages, the exception will be logged.

How can I configure Elmah.MVC?

There is a simple configuration section in web.config file.

<appSettings>
	<add key="elmah.mvc.disableHandler" value="false" />
	<add key="elmah.mvc.disableHandleErrorFilter" value="false" />
	<add key="elmah.mvc.requiresAuthentication" value="false" />
	<add key="elmah.mvc.allowedRoles" value="*" />
    <add key="elmah.mvc.route" value="elmah" />
</appSettings>
  • elmah.mvc.disableHandler - turn on/off ELMAH.MVC handler
  • elmah.mvc.disableHandleErrorFilter - by default HandleErrorAttribute() is set as global filter, to disable it, set value to "true"
  • elmah.mvc.requiresAuthentication - secure /elmah route with authentication
  • elmah.mvc.allowedRoles - in case of authentication is turned on, you can specify exact roles of user that have access (eg. "Admins")
  • elmah.mvc.route - tweek default ELMAH.MVC route

You can either disable handler or apply authentication, based on application roles.

You can also tweek the ELMAH default route. If you just install the package, ELMAH will be availabled at /elmah, howether if you would like to change that, change elmah.mvc.route, this setting is a MVC route prefix, used during ELMAH routes registration. For instance, if you change that to secure/admin/errors you will get ELMAH at http://yourapp.com/secure/admin/errors.

Default route issue

You might change the elmah.mvc.route to a custom one, but still able to see ELMAH reports at /elmah. This issue is caused by the way how ASP.NET MVC matches controllers in separate namespaces. There are no good workaround for that (at least one I know), so if I makes a trouble to you, I recommend to reconsider the application, without using default route.

Related articles and posts

ELMAH.MVC 2.0.1 Update is Out

ELMAH.MVC v.2.0.0 - Release Candidate

ELMAH.MVC v2.0 is coming

Slides of ELMAH.MVC talk

ELMAH MVC controller released on NuGet

Integrating ELMAH to ASP.NET MVC in right way

Recent changes

  • 06-Nov-2012 - v.2.0.2 flag to turn on/off default HandleErrorAttribute()
  • 16-Aug-2012 - v.2.0.1 custom routes, VB.NET support
  • 13-Jun-2012 - v.2.0 major changes, packed to class library, HandleError attribute etc.
  • 11-Jan-2012 - minor style changes and readme correction
  • 29-Aug-2011 - nuget package created
  • 29-Aug-2011 - reimplemented controller to avoid usage of additional routing instructions

About

For painless integration of ELMAH into ASP.NET MVC application

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%