I am developing a Web application in ASP.NET. My project is an application that supports booking hotel online. I am having the following problem: When a client accesses the Web server through a browser to book a room, he checks for available spots. As a result, the spots (if available) that he checked are considered blocked (so another cannot get them). I want to make it so that if the client leaves for another Web page or if he hasn't confirmed in 5 minutes (for example), these spots are released. How I can control this? There are a number of different ways to approach a problem like this. The simplest approach is to rely on the session timeout setting, which defaults to 20 minutes (or, whatever your machine.config or web.config have set for the application). The problem with this approach is that on the one hand, you probably don't want to shorten the session timeout to 5 minutes, nor do you want to wait 20 minutes for the seats to free up. Although you can follow the user's navigation on your site, you can't detect when they leave your site for another, so you want a model that will work for both of these scenarios. One possibility would be to add an entry to the cache for this, tied to this user's session ID, and set the object with a sliding expiry of 5 minutes. Update the sliding expiry each time the user hits a page within the workflow of this seat selection process, and be sure to gracefully notify your users of the expiry of this item when they navigate to a page that expects the seat selection to exist. Other requirements for your application design may influence alternate approaches, but this may help you on your way.
Dig Deeper on Topics Archive