Hi,
I am using ASP.NET MVC2 with NHibernate, but am facing an issue. All calls to the database via NHibernate should be inside a transaction, however code inside the view kicks off database calls in some instances. Thus there is a need to be able to commit the transaction after the view has rendered.
For example displaying a list of users and their user roles you might show the user role using this code: <%: Model.UserRole.Name %>
This will cause a hit on the database as the UserRole is loaded using a NHibernate proxy.
You can fetch the UserRole eagerly which circumvents the issue in this case, but there are cases where it is much faster to use lazy loading.
Anyway, is there a way to run code after the view has rendered?