Reputation:
Can anyone help me in this. Am using Asp.NET WITH C#. I am have an number of products in my database. When I run my code all the products values are stored in a database table. Without an exit button, if I close my application, when I run for second time the database table should be empty. I CANT USE !PAGE.ISPOSTBACK because I add different products at single run time, which will delete for single users. Could anyone tell me, or show code for deleting elements as the application is closed without internal exit button event.
Upvotes: 0
Views: 830
Reputation: 11143
You should add some Cache Item and a Cache Expiration CallBack with SlidingExpiration.
So you can handle deleting all your items when Expiration CallBack is fired whenever the users didn't click on the Exit button.
Check this out : http://geekswithblogs.net/jawad/archive/2005/05/23/CacheManager.aspx
Upvotes: 0
Reputation: 17260
If you are using a web application, there is no real way to determine when a user leaves your app. There are a variety of strategies you can use, but none of them are 100% reliable. These strategies include:
You may wish to reverse the logic here. Why not run some logic when the user logs in to detect these orphaned rows, and delete them?
Upvotes: 1