5

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

1
  • +1 for OMG DATABASE DEAD and also needing the exact help. Commented Oct 14, 2010 at 19:37

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

3 Comments

I tried that, it didnt work...how would it know what controller to go to anyway?
It won't go to a controller, it'll go to the view. If you want to go to a specific controller, you'll have to catch the exception and redirect yourself (I think). You can use the TempData to store the exception details. You may be able to write an ActionFilter to do the job...
It doesn't "go to a controller." It just specifies a view name, like Kieron said. Look at the source code; it's trivial. The view name is resolved like any other view name, first in current controller, then in shared (in the default WebForms ViewEngine, anyway).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.