-
how to catch exception in Controller level (Asp.net MVC)
Hi Guys,
Got a newbie question.
I'm using Asp.net MVC Preview 3 with Spring.net and nHibernate.
Currently, I'm using spring.net to create the controller for me.
And data is persisted to DB through nHibernate at the end of the request which means it perform persistence outside the controller.
How can I catch the exception within the controller.
Cause I want to display the form validation error back to the user and not redirecting them to a generic error page.
thx,
George
-
Hi,
one way to solve this, is to wrap your entity manipulation within a transactional service. If your controller calls this service, any data manipulation will already be committed (or aborted), when the call returns to your controller. This will ensure, that your changes are persisted before your controller is left.
You can check out the Spring Northwind example application to see, how this can be done using OpenSessionInView and a Transaction Aspect. It shouldn't make a difference, whether you use ASPX or MVC as your web ui approach as long as you properly layer your architecture.
cheers,
Erich
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules