How can I coerce an exception message that has bubbled from my business layer into an alert box in javascript?
BTW, I’m using ASP.NET MVC 1.0.
Thanks,
Rod.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Make a custom action filter attribute and apply it to the action method.
In the override version of OnActionExecuted() you’ll have to set the filterContext.Result to some RedirectResult/RedirectRouteResult in order to return anything to the browser as the exception has set it to EmptyResult. So redirect to some error page or controller action which renders html with the javascript for the alert 🙂 Here’s the custom ActionFilter Attribute you could start with:
Gets a bit messy, but I hope answers your question ?