GuestMVCAsync
GuestMVCAsync

Reputation: 597

Handling System.Web.HttpException

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

Upvotes: 0

Views: 3451

Answers (2)

Dan Atkinson
Dan Atkinson

Reputation: 11689

How about a 404 page?

This would be the last of your routes:

routes.MapRoute("NotFound", "{*url}",
  new { controller = "Home", action = "Show404" }
 );

Upvotes: 0

Farinha
Farinha

Reputation: 18091

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

Just like described here.

Upvotes: 2

Related Questions