Manage transaction in ASP.NET MVC application

87 views
Skip to first unread message

Christian I.

unread,
Nov 2, 2012, 11:55:21 AM11/2/12
to nhu...@googlegroups.com
Hello,

I have some doubt abut the good way to manage transaction in an ASP.NET MVC application. I tried this :

1. Create the SessionFactory in he global.asax event Application_Start. In the controller create a session, begin a transaction and commit rollback, like this I can manage to view to return. But I have a lot of duplicate code.

2. I trid to create the session in the Application_BeginRequest event and commit in Application_EndRequest but like this I can't return a specific view and didn't find the way to know if a NHException occur during the transaction

3. I tried the Oren's code http://ayende.com/blog/4809/refactoring-toward-frictionless-odorless-code-what-about-transactions the sessionController is always null

May be the solution ... a mix of 1 and 2, create the session Application_BeginRequest and in the controller do the commit/rollback and return the view I want.

What do you think,

Thanks,
Reply all
Reply to author
Forward
0 new messages