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. loosing data between postbacks [modified]

loosing data between postbacks [modified]

Scheduled Pinned Locked Moved ASP.NET
questiondatabasesysadminhelp
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.
  • A Offline
    A Offline
    Ayman Mashal
    wrote on last edited by
    #1

    Hi in page_load im calling a function that retrieve data from the database private void getLocationStdHours() { string cacheKey = "stdHoursDS"; //the key to get/set our cache'd data LocationsBL Loc = new LocationsBL(); DataSet ds=Loc.GetLocationStdHours(vLocCode); Cache.Insert(cacheKey,ds,null,DateTime.Now.AddHours(1), TimeSpan.Zero); dgLocStdHours.CurrentPageIndex=0; dgLocStdHours.DataSource=((DataSet)Cache["stdHoursDS"]).Tables[0]; dgLocStdHours.DataKeyField="rownum"; Response.Write("before : "+((DataSet)Cache["stdHoursDS"]).Tables[0].Rows.Count); dgLocStdHours.DataBind(); btnNew.Disabled = false; } the data shows fine without problems but when i click the "New Record" button which is a server control private void btnNew_ServerClick(object sender, System.EventArgs e) { DataSet ds = Cache["stdHoursDS"] as DataSet; if(ds == null) { Response.Write("Session timeout - please reload page"); return; } ..... the Cache["stdHoursDS"] is null now !!! but not always in some cases it works sometimes not ? what is the problem here ? Note : this problem just appear when i connect from outside the local lan using VPN or the intranet . its work prfectly from my PC or other PCs in the same lan thanks -- modified at 4:43 Thursday 3rd May, 2007

    K 1 Reply Last reply
    0
    • A Ayman Mashal

      Hi in page_load im calling a function that retrieve data from the database private void getLocationStdHours() { string cacheKey = "stdHoursDS"; //the key to get/set our cache'd data LocationsBL Loc = new LocationsBL(); DataSet ds=Loc.GetLocationStdHours(vLocCode); Cache.Insert(cacheKey,ds,null,DateTime.Now.AddHours(1), TimeSpan.Zero); dgLocStdHours.CurrentPageIndex=0; dgLocStdHours.DataSource=((DataSet)Cache["stdHoursDS"]).Tables[0]; dgLocStdHours.DataKeyField="rownum"; Response.Write("before : "+((DataSet)Cache["stdHoursDS"]).Tables[0].Rows.Count); dgLocStdHours.DataBind(); btnNew.Disabled = false; } the data shows fine without problems but when i click the "New Record" button which is a server control private void btnNew_ServerClick(object sender, System.EventArgs e) { DataSet ds = Cache["stdHoursDS"] as DataSet; if(ds == null) { Response.Write("Session timeout - please reload page"); return; } ..... the Cache["stdHoursDS"] is null now !!! but not always in some cases it works sometimes not ? what is the problem here ? Note : this problem just appear when i connect from outside the local lan using VPN or the intranet . its work prfectly from my PC or other PCs in the same lan thanks -- modified at 4:43 Thursday 3rd May, 2007

      K Offline
      K Offline
      kubben
      wrote on last edited by
      #2

      Normally the only reason why something would be kicked out of the cache before the expiration time is because the web site needed more memory so it would expire the cache before its time. NOTE you are using an absolute expire, so it will for sure expire in 1 hour. So I guess that is a possibility as well. You should write some code checking to see if the object exists in the cache before you try to use it. If it isn't there you will need to add it again. If you didn't mean to force an expire of the dataset in 1hour then you should use the sliding expiriation. Then it will only expire if it hasn't be used for a certain period of time. Hope that helps. Ben

      A 1 Reply Last reply
      0
      • K kubben

        Normally the only reason why something would be kicked out of the cache before the expiration time is because the web site needed more memory so it would expire the cache before its time. NOTE you are using an absolute expire, so it will for sure expire in 1 hour. So I guess that is a possibility as well. You should write some code checking to see if the object exists in the cache before you try to use it. If it isn't there you will need to add it again. If you didn't mean to force an expire of the dataset in 1hour then you should use the sliding expiriation. Then it will only expire if it hasn't be used for a certain period of time. Hope that helps. Ben

        A Offline
        A Offline
        Ayman Mashal
        wrote on last edited by
        #3

        the problem is not appearing while i run the application in the local network ! i face the problem when i run the form throug VPN or remote connection which is slower . i am not loosing the data after a long time i am loosing it immediately after a postback which takes less than 2 seconeds and this happening sometimes from the first postback sometimes after 10 postbacks. for now what i did is checking if the Dataset in the cache is still exists or not if not i am generating it again which means loosing the not saved changes . but i want if there is an IIS configurations that could affect the cache ? many thanks.

        K 1 Reply Last reply
        0
        • A Ayman Mashal

          the problem is not appearing while i run the application in the local network ! i face the problem when i run the form throug VPN or remote connection which is slower . i am not loosing the data after a long time i am loosing it immediately after a postback which takes less than 2 seconeds and this happening sometimes from the first postback sometimes after 10 postbacks. for now what i did is checking if the Dataset in the cache is still exists or not if not i am generating it again which means loosing the not saved changes . but i want if there is an IIS configurations that could affect the cache ? many thanks.

          K Offline
          K Offline
          kubben
          wrote on last edited by
          #4

          IIS controls a couple of things. In the app pool there is a recycle app pool that would re-set your entire web application, this includes the cache. By default this re-set happens like every 27 hours or something weird like that. Normally, I change it to recycle real early in the morning like 3am. The web site it self has many timeout settings for the session. I don't see any reason why a session expiring would affect the cache. I guess the question is how much data are you putting into web server memory when the post back occurs. If you are putting huge amounts of data into you web server memory then the cache could be cleared early because the server is running out of memory. Hope that helps. Ben

          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