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

  • Home
  • SEARCH
  • 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 3806146
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T14:47:22+00:00 2026-05-19T14:47:22+00:00

I am getting Nhibernate Session closed exception with asp.net mvc telerik ajax grid. The

  • 0

I am getting Nhibernate Session closed exception with asp.net mvc telerik ajax grid. The grid is bound to an entity Sale that has a related entity User. The exception thrown is when trying to access the User entity. I have used the fetchMode to eager load it but I still get the same exception. This exception only occur if I switch between the grid pages multiple times. Anyone encountered this issue?

The code for that data access is as follow:

public IList<Sale> List()
        {
            var manager = new ManagerFactory().GetSaleManager();
            var iCriteria = manager.Session.GetISession().CreateCriteria(typeof(Sale))
                .SetFetchMode("AspnetUser3.Agents3", FetchMode.Eager);

            return iCriteria.List<Sale>();
        }

The code that try to access the related object in the object graph is as follow:

AgentId = sale.AspnetUser3.Agents3[0].Id,

The exception thrown

NHibernate.Exceptions.GenericADOException: could not load an entity: [SalesEntry.Data.Model.AspnetUser#7aaabf99-d77d-4edf-b949-9c4c0f3e85d8][SQL: SELECT aspnetuser0_.[UserId] as column1_12_0_, aspnetuser0_.[UserName] as column2_12_0_, aspnetuser0_.[LoweredUserName] as column3_12_0_, aspnetuser0_.[MobileAlias] as column4_12_0_, aspnetuser0_.[IsAnonymous] as column5_12_0_, aspnetuser0_.[LastActivityDate] as column6_12_0_, aspnetuser0_.[ApplicationId] as column7_12_0_ FROM [dbo].[aspnet_Users] aspnetuser0_ WHERE aspnetuser0_.[UserId]=?] ---> System.ObjectDisposedException: Session is closed!
Object name: 'ISession'.
  • 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-19T14:47:22+00:00Added an answer on May 19, 2026 at 2:47 pm

    It’s happening because User is being lazy loaded and you’re likely seeing a situation where the session is being closed before the User object is loaded. Then when the Grid accesses the User reference you get this exception. Make sure you’re following the Unit of Work pattern.

    Also you may want to use a Model class to bind to your grid, rather than the entity directly. That way you control what kind of access is done and you avoid having unexpected changes to your entities/database.

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

Sidebar

Related Questions

I am getting the folloinwg error from NHibernate: System.ObjectDisposedException: Session is closed! Object name:
I have NHibernate hooked up in my asp.net mvc app. Everything works fine, if
I'm running into issues with my ISessions in NHibernate. I keep getting Session Closed!
I am somehow getting a Session is closed exception. When serializing an a JPA2
I'm using NHibernate behind my ASP.NET MVC application and I've come across a frustrating
Ok so I 'm just getting into nhibernate (using fluent). One thing that I
I am using NHibernate on a new ASP.NET project, and am running into what
I'm trying to access the current hibernate session in a test case, and getting
I am successfully getting Fluent NHibernate to update my database by calling UpdateBaseFiles: Public
Getting started with NHibernate How can I generate identity fields in nHibernate using Hilo

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.