ASP.NET MVC View and Transaction - Kazi Manzur Rashid's(weblogs.asp.net)
submitted by
mithu(570) 2 years, 3 months ago
Scott showed how to render the Grid in a Transaction. Certainly it does the job but in my opinion view component should not be responsible for this kind of cross cutting concerns, instead we can use the Action Filters. Lets see how we can utilize the Action Filter in this scenario instead of modifying the Grid code. What Scott is trying to do is encapsulate the data access operation in a transaction, the Action Filter has several methods which the ASP.NET MVC framework executes in different stages of a request. In this case, we will use the OnActionExecuting which fires before the code enters into the controller method to start a transaction and OnResultExecuted which fires when the view is processed, we will commit/rollback based upon the status, here is the code that would process the action result in a transaction:
|category: ASP.NET
|Views: 272
tags:
ASP.NET another
Everyones tags:
Your Tags: