Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Session not available in VirtualPathProvider

Session not available in VirtualPathProvider

Scheduled Pinned Locked Moved ASP.NET
helptutorialquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    walkTheNet
    wrote on last edited by
    #1

    Hello guys, I'm struggling a problem now for some days. Hopefully one of you guys can help me out with that. I wrote my own VirtualPathProvider and VirtualPathFile to make it possible to load different pages from different locations. It works very good. But now I need to load the pages from different locations depending on a value stored in the session. The time when VirtualPathprovider is invoked the Session object is not available or lets say it's available but null. Now I found out that the session object is filled when the AcquireSessionState event is invoked, but thats to late for me because the action of loading the page already passed. So now I want to create the session by my own before the AcquireSessionState is invoked. But I don't know how to fill the session object by my own. Does anybody can help me with this problem? Or has anybody a better idea then filling the session object by my own. Thanks a lot for any input Oliver

    P 1 Reply Last reply
    0
    • W walkTheNet

      Hello guys, I'm struggling a problem now for some days. Hopefully one of you guys can help me out with that. I wrote my own VirtualPathProvider and VirtualPathFile to make it possible to load different pages from different locations. It works very good. But now I need to load the pages from different locations depending on a value stored in the session. The time when VirtualPathprovider is invoked the Session object is not available or lets say it's available but null. Now I found out that the session object is filled when the AcquireSessionState event is invoked, but thats to late for me because the action of loading the page already passed. So now I want to create the session by my own before the AcquireSessionState is invoked. But I don't know how to fill the session object by my own. Does anybody can help me with this problem? Or has anybody a better idea then filling the session object by my own. Thanks a lot for any input Oliver

      P Offline
      P Offline
      peacefulmember
      wrote on last edited by
      #2

      A thought!..Can you use cookieContainer!! or HttpApplication instance!!

      W 2 Replies Last reply
      0
      • P peacefulmember

        A thought!..Can you use cookieContainer!! or HttpApplication instance!!

        W Offline
        W Offline
        walkTheNet
        wrote on last edited by
        #3

        Hi, Thanks for the input, but I use cookieless sessions. I tried to retrieve session data from different locations: HttpContext.Current.Session - null at this time HttpContext.Current.ApplicationInstance.Session - null at this time as well I guess thats because the AcquireSessionState is called later on - where the session object is filled. What I want to do now is to try initialize the Session earlier, but I don't know if it's possible. Thanks Oliver

        1 Reply Last reply
        0
        • P peacefulmember

          A thought!..Can you use cookieContainer!! or HttpApplication instance!!

          W Offline
          W Offline
          walkTheNet
          wrote on last edited by
          #4

          Hi peacefulmember, I have to apologize. I use cookies without my knowledge :-) Now that I know that I use cookies I found out that there is a cookie in which the session id is stored. I save now the value which I wanted to store in the session also in the cache with following statement: Cache[Session.SessionID + "_MyKey"] = Value; The difference to just saving it in the session is that the cache is available every time and the cookies are already present at the time I need to get the value. So in my VirtualFile I added following code to retrieve the value again: if (HttpContext.Current.Request.Cookies["ASP.NET_SessionId"] != null) { value = (String)System.Web.Hosting.HostingEnvironment.Cache[HttpContext.Current.Request.Cookies["ASP.NET_SessionId"].Value + "_MyKey"]; } That solved the problem for me. It's kind of a workaround. I would have preferred the "Session-Solution" but as the Session is not filled that time I have to solve it this way. Thanks Oliver

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups