Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3932866
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T23:32:14+00:00 2026-05-19T23:32:14+00:00

I need some insights and thoughts about a refactoring I’m about to do to

  • 0

I need some insights and thoughts about a refactoring I’m about to do to our web-app.

We initially used the session-per-request pattern with NHibernate and ActiveRecord by using the On_BeginRequest / On_EndRequest in the HttpApplication to create and dispose the session. Later on, we realized that any DB-related exceptions got thrown outside of our monorail-context, meaning that our rescues didn’t kick in. As another sideeffect, we didn’t have the option to fully skip creation of NHibernate sessions in any action, which in some cases would be desirable.

So we rewrote it to create sessions in Initialize() / Contextualize() in our base controller, and disposed them in the Dispose() of our base controller. We also Rollback the session in our rescue controller to prevent any half written changes to the DB. So far, so good. The reason for doing it in the Dispose() is because we want it to live through the view-rendering, because of lazy-loading reasons aswell as viewcomponents that needs to get a session (we could switch to units-of-work for the viewcomponents, but they don’t seem to have a Dispose()…)

However, I’m experiencing some deadlock issues where we have started transacations in the DB that isn’t getting rollbacked nor committed and I can’t get my head around it, mostly because of the mess we’ve made with this approach…

So I found this article: http://hackingon.net/post/NHibernate-Session-Per-Request-with-ASPNET-MVC.aspx

And I thought, “Filters, we can use that in MonoRail too!”, because it can kick in on BeforeAction and AfterRendering.

My questions then are:

  1. What happens if an Exception occurs in the filter?
  2. Will AfterRendering fire even if an Exception occurs in the action or the rendering?
  3. Would you recommend this approach, if not, what are your suggestion instead?

Any pointers are very much appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T23:32:15+00:00Added an answer on May 19, 2026 at 11:32 pm
    1. You need an application error handler to care of exception handling.

    2. Attach a debugger and find out.

    3. Probably not (even though it is my article). It doesn’t work with RenderAction. Best to use an IoC container to control the lifetime of connections.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need some sort of interactive chart control for my .NET-based web app. I
I need some information about localization. I am using .net 2.0 with C# 2.0
I'm looking for some quick thoughts about a business application I am looking to
I am designing a web app that has some information that needs to be
I need some advice as to how I easily can separate test runs for
I need some info on how to use margins and how exactly padding works.
I need some software to explore and modify some SQLite databases. Does anything similar
I need some help from the shell-script gurus out there. I have a .txt
We need some input on what is a good design pattern on using AJAX
I need some basic CMS functionality with rich text editing. On stack overflow there

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.