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 3845240
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T16:12:50+00:00 2026-05-19T16:12:50+00:00

I have an MVC3 app that’s using NHibernate. All was going well until I

  • 0

I have an MVC3 app that’s using NHibernate. All was going well until I started to try and add second level caching. After browsing the web for a few hours I finally found what I think is the right dll (NHibernate.Caches.SysCache2.dll) and have added it to my project.

However, I can’t find any help for configuring it with an MVC app. All the examples refer to having an App.config file (I presume this is for Web Forms). I’m a Java developer who’s learning .Net so I’m not so familiar with how to rig everything up.

Could someone point me in the right direction. I’m using xml hibernate (hbm) files.

Thanks.

  • 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-19T16:12:50+00:00Added an answer on May 19, 2026 at 4:12 pm

    I’m using 2nd level caching with MVC3 and NHibernate.Caches.SysCache.dll like this…

    1st, add a config section to your web.config file like this

    <configSections>
        <section name="syscache" type="NHibernate.Caches.SysCache.SysCacheSectionHandler, NHibernate.Caches.SysCache, Version=3.0.0.4000, Culture=neutral, PublicKeyToken=6876f2ea66c9f443"/>
    </configSections>
    

    add a syscache section to your web.config under your configuration section like this:

    <syscache>
        <cache region="SomeCustomNameRegion" expiration="86400" priority="5" />
    </syscache>
    

    in my hibernate.cfg.xml file i have the following properties added:

    <property name="cache.provider_class">NHibernate.Caches.SysCache.SysCacheProvider, NHibernate.Caches.SysCache</property>
    <property name="cache.use_query_cache">true</property>
    <property name="cache.use_second_level_cache">true</property>
    

    I’m using FluentNhibernate to create my mappings and add this to support caching:

    public CustomerClassMap()
    {
        Cache.NonStrictReadWrite();
        Id(x => x.Id);
        Map(x => x.Name);
        //... more properties
    }
    

    And then in my data access code, I have something similar to this for queries that I want cached:

    public IEnumerable<Customer> GetAllCached()
    {
        return Session.CreateCriteria(typeof(Customer))
                .SetCacheable(true)
                .SetCacheRegion("SomeCustomNameRegion")
                .SetCacheMode(CacheMode.Normal)
                .AddOrder(Order.Desc("CreateDate"))
                .List<Customer>();
    }
    

    Here are some helpful links to get into a little more detail. There’s nothing specific about MVC3 that you need to worry about, and most is unchanged from earlier versions of NHibernate as far as i can tell.

    http://www.klopfenstein.net/lorenz.aspx/using-syscache-as-secondary-cache-in-nhibernate

    http://blog.symbiotic-development.com/2008/02/27/more-configuring-nhibernate-caches/

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

Sidebar

Related Questions

I am building a MVC3 app using Ninject framework. I have a service that
I have an MVC3/EF4.1 app that I'm building which now works fine on my
I have a C# .Net web app using MVC3. I am using Aspose to
I have mvc3 web app. inside that I have one Enquiry form once I
I have a vb.net MVC3 Razor app that generates PDF files. The problem is
I have an MVC3 app, using EF, where one table winds up in a
I have an MVC3 app that has a details page. As part of that
I have an ASP.NET MVC3 app that features a form with a nested-table input
I have an MVC3 app written in C# that I'd like to generate rel=canonical
I have an asp.net mvc3 Razor app being developed in VS2010 using Git for

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.