• Stars
    star
    266
  • Rank 154,103 (Top 4 %)
  • Language
    C#
  • License
    Apache License 2.0
  • Created over 13 years ago
  • Updated 5 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Painless integration of ELMAH into ASP.NET MVC application

ELMAH.MVC

Build status Join the chat at https://gitter.im/alexbeletsky/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 be logged in "customError='On'" mode?

Yes, even if 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.IgnoreDefaultRoute" value="false" />
	<add key="elmah.mvc.allowedRoles" value="*" />
	<add key="elmah.mvc.allowedUsers" value="*" />
	<add key="elmah.mvc.route" value="elmah" />
	<add key="elmah.mvc.UserAuthCaseSensitive" value="true" />
</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.allowedUsers - in case of authentication is turned on, you can specify exact users that have access (eg. "johndoe")
  • elmah.mvc.route - configure ELMAH.MVC access 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.

UPDATE: You might also consider ignoring /elmah route explicitly as described here.

UPDATE 2: @chaoaretasty has added an option, to allow ignoring default role. Set elmah.mvc.IgnoreDefaultRoute setting option to true.

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

  • 30-Apr-2015 - v.2.1.2 Added UserAuthCaseSensitive setting by @issafram. IgnoreDefaultRoute now works for subfolders by @DavidDeSloovere.
  • 09-Jul-2013 - v.2.1.1 fixes by @papci
  • 01-Jul-2013 - v.2.1.0 user based authentication by @papci
  • 02-Jun-2013 - v.2.0.3 ignoring default role by @chaoaretasty
  • 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

Licence

Apache 2.0

More Repositories

1

backbone-express-spa

Backbone.js + Express.js single page application boilerplate
JavaScript
431
star
2

ng-notifications-bar

Angular.js component for stylish and flexible top bar notifications.
JavaScript
149
star
3

backbone-computedfields

Computed fields for Backbone.Model
JavaScript
135
star
4

brick

My boilerplate project for Node.js / React.js development
JavaScript
71
star
5

github-commits-widget

Simple javascript widget to show recent github commits
JavaScript
41
star
6

foundstyles

Cool looking and ready to use themes based on Foundation framework
JavaScript
30
star
7

candidate

Simple and nice continuous delivery for .NET web applications.
JavaScript
23
star
8

machiatto

Behaviour driven test framework.
JavaScript
23
star
9

toml-js

TOML parser implementation (node.js + browser)
JavaScript
23
star
10

dokku-bower-install

Dokku pluging to install bower dependecies
Shell
21
star
11

tdd.demand

A Web Crawler that crawle some job looking sites, analyze them, store data
C#
19
star
12

trackyt.net

New task tracking/time management application
JavaScript
17
star
13

ddp-server-event

The implementation of DDP server based on EventEmitter.
JavaScript
15
star
14

react-restify-isomorphic

Isomorphic, react-based application.
JavaScript
13
star
15

wonka

Sweet blog engine with github powered backend for ASP.NET MVC applications.
C#
9
star
16

sparkling

Building Reactive API's with Express.js and MongoDB
JavaScript
9
star
17

todomvc-aura

TodoMVC based on Aura
JavaScript
9
star
18

aspnet.mobile

Mobile Web Application for ASP.NET portal fans
JavaScript
9
star
19

beerncode

Kyiv Beer'n'Code website
C#
9
star
20

react-notifications-bar

The port of ng-notifications-bar to React
JavaScript
6
star
21

react-grunt-es6

React + Grunt + ES6
JavaScript
6
star
22

react-gulp-es6

React + Gulp + ES6
JavaScript
6
star
23

github-fs

Convenient way of working with Git (Github) remote repository as file system
C#
5
star
24

backbone-clickdebounce

Debounce multiple clicks for Backbone.Views
JavaScript
5
star
25

themailer

Demo application I've created for my conference talk
JavaScript
5
star
26

rest.mvc.example

Example of REST service by ASP.net MVC2 framework (for blog)
JavaScript
5
star
27

node-dev-server

Ideal for local single page applications development
JavaScript
3
star
28

10k

My humble attempt to participate 10K Appart competetion
JavaScript
3
star
29

freeze

Easy way of making a snapshot of dynamic web site.
JavaScript
3
star
30

js-training

js-training
JavaScript
2
star
31

certificates

My archivements on online courses and other official stuff
2
star
32

benchmark-js

Very simple, javascript Date() dependable, console based benchmarking.
JavaScript
2
star
33

tdd-starter

Ready to use sandbox for TDD with JS
JavaScript
2
star
34

copter

Front-end apps deployment
1
star
35

alexbeletsky.github.io

My personal page and development blog
HTML
1
star
36

canteen

Node.js chat application with real time collaboration
JavaScript
1
star
37

ml-python

Materials created during studying Python Machine Learning book.
Jupyter Notebook
1
star
38

next-error

Express.js module that would which eliminates if / return for error handling.
JavaScript
1
star
39

numa-app

JavaScript
1
star
40

docker-deploy

Deploy tool for remote docker server
Shell
1
star
41

gameoflife

The Game of Life
JavaScript
1
star
42

backbone-aspnetmvc-spa

Backbone.js + ASP.NET MVC (Web API) single page application boilerplate
JavaScript
1
star