to set Application value when Session is going to end?

legendgod

Regular
Joined
May 17, 2004
Messages
53
Location
Hong Kong
Hello everyone. I have a problem in writing a function of web service.
In the web service, there is a function which available to one user only at one time. Therefore, I write some code in global.ascx like:

Code:
Application.Add(("SchHHGInUse"& Dt.Rows(i).Item("hhgId")),-1)
whenever the first user use the function, it change the value in application to his userId. Therefore any other user can see the change and do not allowed to use the function.

When the first user click "QUIT" button or "LOGOUT", the value in application will change back to -1. Therefore the next users can use the function now.

However, since most users seems not likely to obey the rule. Which just click X button at the windows right top end. Will cause the function be locked from any other users....

My problem is, since the user information is stored in his own session. At the time the session timeout, the server cannot unlock the value of Application too! (because server do not know whether the current user of function is timeouted or not)

I am quite a newbie to this type of web service. Please give me any idea you have. It will be helpful! Thank you!
 
Is there a reason this function can only be accessed by one user at a time - this kind of behaviour can make your life a lot more difficult.
If you are restricting your web service to one user till they log out (the impression I got from your post) then you are going to have serious scalability issues with this scenario.
It may be better to post what the application / web service are doing and see if anyone has a better suggestion for the application architecture.
 
I agree with Derek. You can't do it..... that way.

I have one solution. Not like you wanted it but one solution anyway.

Make this "function" usable only by 1 user­. 1 login permitted at a time and logoff the user after 20min or 30 or any.... (ever if it's still alive). I'm sure that THIS is possible.
 
i see...

First of all, thank you for your reply. Let me tell more details ... In fact the function I mentioned is the scheduling management function. All the manager of different teams can only access their teams' schedule. Some of manager can access to more than 1 team and some of teams have more than 1 manager (from 1-5). I don't want the managers access and update the schedule at the same time because they may not get the latest version if someone is editing.

I want to try Arch4ngel's idea but I have no idea how to count the access time of users...
 
There is no easy reliable way to do this - if you want to only allow one person in at a time and then only time them out after 20 or 30 minutes you are looking at restricting your application to 2 or 3 users per hour - pretty unacceptable I would say.

If the system can be updated by multiple people then there needs to be some other mechanism in place to either prevent conflicting updates or to make sure changes are visible - this may be as simple as after a change is made requery the data and redisplay it, it is then up to the manager to check nothing was amended that conflicts with his update.
If you really require only one update / user then web services are not the technology to choose and you may be better of going with a windows forms / transaction based application instead.
 
Back
Top