0

Any request to a non existent file or folder is throwing the following exception on my MVC project;

System.Web.HttpException: The controller for path ... could not be found or it does not implement IController

Important Edit:

I would like to handle this case so that this exception does not go into my Elmah logs.

Whatever I do inside global.asax Application_Error goes to Elmah logs

GuestMVCAsync
  • 577
  • 3
  • 7
  • 10

2 Answers2

2

You can handle the exception in the Application_Error() method in Global.asax

Just like described here.

Community
  • 1
  • 1
Farinha
  • 17,636
  • 21
  • 64
  • 80
0

How about a 404 page?

This would be the last of your routes:

routes.MapRoute("NotFound", "{*url}",
  new { controller = "Home", action = "Show404" }
 );
Dan Atkinson
  • 11,391
  • 14
  • 81
  • 114
  • I cant use this while i have my default route which i don't want to remove; "{controller}/{action}/{id}", new { controller = "Home", action = "Index", id = "" } – GuestMVCAsync Jan 29 '10 at 14:54
  • Why not? This NotFound route would be the very last route in your list. It has be the last because ASP.NET MVC will match the first route it comes to, and this will match **any** route. – Dan Atkinson Jan 29 '10 at 15:00