locked
Unable to retrieve the session data from the velocity cache RRS feed

  • Question

  • How to retrieve the session data from the velocity cache (i.e how do I get the values from Velocity which I inserted using asp session.add)
    I have the required session state settings in the config file as follows

    <

     

    sessionState mode="Custom" customProvider="Velocity">
    <
    providers>
    <
    add name="Velocity" type="Microsoft.Data.Caching.DataCacheSessionStoreProvider, ClientLibrary" cacheName="default"/>
    </
    providers>
    </
    sessionState>

    I used the cacheutil.cs from the CTP3 sample

    When I try session.Add(emp.ID,emp), I expect this object to be saved in Velocity cache. MS Velocity document says that there is no need to change a single line of code.

    Where Am I going wrong? Please reply at the earliest.
    Thursday, July 30, 2009 4:46 AM

Answers

  • Hi Srinat,

    "When I try session.Add(emp.ID,emp), I expect this object to be saved in Velocity cache. MS Velocity document says that there is no need to change a single line of code."

    When you use Velocity as SessionProvider in an ASP.Net application, it stores all sessions in a namedCache you specify in web.config but your item KEY (emp.id, which is added in session) is NOT the same one that Velocity SessionProvider uses to store your Session data.
    Just use Session as you're accustomed to do:

    Session["12345"]=emp;
    myEmp=(employee)Session["12345"];

    HTH

    Andrea Colaci
    Thursday, July 30, 2009 9:17 AM

All replies

  • Hi Srinat,

    "When I try session.Add(emp.ID,emp), I expect this object to be saved in Velocity cache. MS Velocity document says that there is no need to change a single line of code."

    When you use Velocity as SessionProvider in an ASP.Net application, it stores all sessions in a namedCache you specify in web.config but your item KEY (emp.id, which is added in session) is NOT the same one that Velocity SessionProvider uses to store your Session data.
    Just use Session as you're accustomed to do:

    Session["12345"]=emp;
    myEmp=(employee)Session["12345"];

    HTH

    Andrea Colaci
    Thursday, July 30, 2009 9:17 AM
  • I've read the link which said.

    "item KEY (emp.id, which is added in session) is NOT the same one that Velocity SessionProvider uses to store your Session data.
    Just use Session as you're accustomed to do:

    Session["12345"]=emp;
    myEmp=(employee)Session["12345"];"


    so how do I pick up from velocity sessionprovider then?
      or

    will using Session["12345"]=emp;myEmp=(employee)Session["12345"];"  internally get stored/retrieved  through velocity cache
    Thursday, August 6, 2009 8:17 AM