Chris James
Chris James

Reputation: 11701

Custom Error handling in ASP MVC

I want to go beyond the default error handling given in ASP mvc. I have an errors controller, so I can hopefully give different error messages according to whats happened: i.e Invalid arguments, Permission denied, OMG DATABASE DEAD, etc.

But I cant seem to work out how to do this, this is what I have tried:

[HandleError(View="/Errors/InvalidArgument",ExceptionType=typeof(ArgumentException))]

It ends up giving a Runtime Error.

Also, on the same subject, is it possible to add more parameters that I could pass to the error controller, such as:

[HandleError(View="/Errors/InvalidArgument",ExceptionType=typeof(ArgumentException), Error="dumb arguments")]

Thanks

Upvotes: 5

Views: 3168

Answers (1)

Kieron
Kieron

Reputation: 27107

Just specify the View name, not it's path...as for passing arguments, I don't think you can.

Upvotes: 2

Related Questions