I am writing my code in MVC3 and C#. I want to send user friendly messages to the user when exceptions and custom exceptions occur. I am thinking of using JSON and jQuery popup boxes.
Can you tell me how to do this? Is there a tutorial or article on this topic?
EDIT:
I want to create custom ActonFilter that extends IExceptionFilter. The custom filter catches exceptions (if they are thrown) and returns custom class ShowMessage(ex). The custom class returns JSON result containing the desired message. In the jQuery there is a parser that shows the popup box with the message (if there is an exception).
There are a number of ways to go about doing this if I seem to understand your question correctly.
My controller would look like this:
My view would then look something like:
This is a simple example of a contact page with full functionality for ajax and warning the user of when something is happening via a loading div with a css background of an animated gif and also letting them know their outcome success/fail.
You can also achieve a similar effect and more by using an ActionResult, calling that and returning Content
This later half – just consider it as pseudo code as I just wrote it up on the fly but should work with small tweaks.
Hopefully this is of help to you and I don’t get laughed at for doing something incorrectly, however, if I did and someone can show me a better way I would love to better myself as well 🙂