I think expiration=DateTime.Now.AddMInutes(30) in login click event affect FromDays(1).
am I right?
if yes what's the relation between them?
how can I solve it?
hi,
I put this code in web.config
<caching>
<cache disableMemoryCollection = "true"
disableExpiration = "false"
privateBytesLimit = "0"
percentagePhysicalMemoryUsedLimit = "90"
privateBytesPollTime = "00:02:00"/>
</caching>
but no success.
and I face another problem that I think it's related to above problem.
I have a cateogry of product when I click on a category I send categoryid via querystring to another page and fetch iformation about that
Data stored in the Cache object will be cleared whenever the application is restarted.
Application will restart in several scenarios. Some of the are as follows...
1)Whenever Machine.Config, Web.Config, Global.asax files are modified.
2)After every 15 modifications ( or 15 recompilations ) of aspx, ascx or asax files application will restart. Actually this limit is specified using <compilation numRecompilesBeforeAppRestart= /> setting in machine.config and can be overridden in Web.Config.
3)Whenever .cs or .vb files in App_Code are updated.
4)Whenever new assemblies are added or deleted.
5)Sub-Directories of Application are deleted or renamed.
Bahare Feizi
Member
30 Points
39 Posts
Items of Shopping cart (stroed in cache) get removed in wrong time
Dec 25, 2012 05:34 PM|LINK
Hi,
I wrote this code for inserting Items in shopping cart and I expect one day Shopping Cart Items be available.
if (Cache[username] == null) { ShoppingCart cart = new ShoppingCart(); Cache.Insert(username, cart, null, DateTime.MaxValue, TimeSpan.FromDays(1)); } if (!Page.IsPostBack) BindGrid();but after 30 minutes items get removed.
and I have this code in login button click event
if (chk_rememberme.Checked) { expiration = DateTime.Now.AddMonths(1); } else { expiration = DateTime.Now.AddMinutes(30); } FormsAuthenticationTicket AuthTicket = new FormsAuthenticationTicket(1, txt_uname.Text, DateTime.Now, expiration, false, role);I think expiration=DateTime.Now.AddMInutes(30) in login click event affect FromDays(1).
am I right?
if yes what's the relation between them?
how can I solve it?
sameer_khanj...
Contributor
7060 Points
1378 Posts
Re: Items of Shopping cart (stroed in cache) get removed in wrong time
Dec 26, 2012 04:33 AM|LINK
I think you can store cart in profile (aspnet DB) To avail for next login or perticular time if user not placed order.
http://www.codeproject.com/Articles/281602/ASP-NET-Profile-Provider
Also Please check below link for shopping cart implimentation:
http://www.asp.net/web-forms/tutorials/aspnet-45/getting-started-with-aspnet-45-web-forms/shopping-cart
sameer.khanjit@gmail.com
View Blog
Click "Mark as Answer" on the post that helped you.
Bahare Feizi
Member
30 Points
39 Posts
Re: Items of Shopping cart (stroed in cache) get removed in wrong time
Dec 26, 2012 06:55 AM|LINK
Thanks Sameer
Yes I Can do it by profile or session or by table.
but I want to do it by Cache and I'd like to know what's the problem here.
If I don't find an answer for it mybe I do it by table.
sameer_khanj...
Contributor
7060 Points
1378 Posts
Re: Items of Shopping cart (stroed in cache) get removed in wrong time
Dec 26, 2012 07:29 AM|LINK
Please read may help you to avoid automatic cache clear
http://johnsadventures.com/2006/02/15/why_does_my_aspnet_cache_keep_clearing_i/
sameer.khanjit@gmail.com
View Blog
Click "Mark as Answer" on the post that helped you.
Bahare Feizi
Member
30 Points
39 Posts
Re: Items of Shopping cart (stroed in cache) get removed in wrong time
Dec 26, 2012 10:46 AM|LINK
Thanks.
I will test and let you know if there was any success.
thanks for all links you put here.
Bahare Feizi
Member
30 Points
39 Posts
Re: Items of Shopping cart (stroed in cache) get removed in wrong time
Dec 26, 2012 01:12 PM|LINK
hi,
I put this code in web.config
<caching>
<cache disableMemoryCollection = "true"
disableExpiration = "false"
privateBytesLimit = "0"
percentagePhysicalMemoryUsedLimit = "90"
privateBytesPollTime = "00:02:00"/>
</caching>
but no success.
and I face another problem that I think it's related to above problem.
I have a cateogry of product when I click on a category I send categoryid via querystring to another page and fetch iformation about that
from database and bind them in repeater
this is first line of code
<asp:Repeater ID="rpt_lookpd" runat="server" EnableViewState="false">
I found product doesn't show in second page but before there wasn't this problem.
when I removed EnableViewState="false" It worked again.
I don't know what's problem.
I think it's too hard to discover what's the problem.
so mybe I keep items in table or session.
thanks.
PrashanthRed...
Member
559 Points
94 Posts
Re: Items of Shopping cart (stroed in cache) get removed in wrong time
Dec 26, 2012 08:24 PM|LINK
Hi Bahare Feizi
Regarding Cache issue:
Data stored in the Cache object will be cleared whenever the application is restarted.
Application will restart in several scenarios. Some of the are as follows...
1)Whenever Machine.Config, Web.Config, Global.asax files are modified.
2)After every 15 modifications ( or 15 recompilations ) of aspx, ascx or asax files application will restart. Actually this limit is specified using <compilation numRecompilesBeforeAppRestart= /> setting in machine.config and can be overridden in Web.Config.
3)Whenever .cs or .vb files in App_Code are updated.
4)Whenever new assemblies are added or deleted.
5)Sub-Directories of Application are deleted or renamed.
6)The CAS policy is modified.
Thanks,
Prashanth Reddy
sameer_khanj...
Contributor
7060 Points
1378 Posts
Re: Items of Shopping cart (stroed in cache) get removed in wrong time
Dec 27, 2012 04:26 AM|LINK
I think you should need to make "EnableViewState =true"
For more information please view :-
http://msdn.microsoft.com/en-us/library/system.web.ui.control.enableviewstate.aspx
http://forums.asp.net/t/1378945.aspx/1
http://stackoverflow.com/questions/5485850/minimizing-viewstate-confused-by-enableviewstate-and-viewstatemode-in-asp-n
sameer.khanjit@gmail.com
View Blog
Click "Mark as Answer" on the post that helped you.
Bahare Feizi
Member
30 Points
39 Posts
Re: Items of Shopping cart (stroed in cache) get removed in wrong time
Dec 27, 2012 09:26 AM|LINK
hi sameer
Excuse me I didn't think you come to this thread again.
I saw your answers just now.
I asked this question in this thread
http://www.aspforums.net/Threads/120987/Items-of-Shopping-cart-stroed-in-cache-get-removed-in-wrong-time/
and I asked support group of my host and the answer was
recycle worker processes 60 minutes
but shopping cart get empty after 30 minutes not 60.
and I mistakly marked that answer in that thread as answer.
I asked the modarator of taht site to open my question again.
and i will read your answers more carefully.
if there was any success I let you know.