473,387 Members | 1,572 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

One person at a time...

Is there any way I can write a asp script such that if one user is
using it no other person can access that page until the processing is
complete...?
--deostroll

Jun 22 '07 #1
8 1541
deostroll wrote:
Is there any way I can write a asp script such that if one user is
using it no other person can access that page until the processing is
complete...?
--deostroll
Just to be clear, there is no such thing as an "asp script". ASP is a
"platform" that supports the execution of various scripting languages,
including vbscript and jscript. I will assume you are talking about
vbscript, although the answer is similar for jscript. There are several
options, but i think the simplest is to utilize an Application variable:

<%
application.lock
application("I_am_locked") = true
application.unlock

'do stuff

application.lock
application("I_am_locked") = false
application.unlock
%>

You can find the ASP Scripting documentation here:
http://msdn.microsoft.com/library/en...f33a651779.asp
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jun 22 '07 #2
deostroll wrote:
Is there any way I can write a asp script such that if one user is
using it no other person can access that page until the processing is
complete...?
--deostroll
Oh wait, it's a little more complex than that. I will reply later with a
better reply if nobody beats me to it.
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jun 22 '07 #3
On Jun 22, 10:08 pm, "Bob Barrows [MVP]" <reb01...@NOyahoo.SPAMcom>
wrote:
deostroll wrote:
Is there any way I can write a asp script such that if one user is
using it no other person can access that page until the processing is
complete...?
--deostroll

Oh wait, it's a little more complex than that. I will reply later with a
better reply if nobody beats me to it.
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Hey bob, what if I just had a text file (locked.txt) that would read
either a 'yes' or 'no'. No in my asp code I could do some ordinary
file handling to access that text file. I can read the content of the
text file. If it reads 'no' then I can

a) truncate the text file and write yes into it, and
b) go on with the processing

or else give a message - "sorry this page is locked!!!"?

Jun 22 '07 #4
deostroll wrote:
Is there any way I can write a asp script such that if one user is
using it no other person can access that page until the processing is
complete...?
--deostroll
I think this will work better. I've incorporated a 15 second timeout - you
can adjust it to whatever fits your scalability needs:

<%
dim guid, TypeLib, start, t
'generate a unique id (GUID)
Set TypeLib = CreateObject("Scriptlet.TypeLib")
guid=Left(CStr(TypeLib.Guid), 38)

start=Now()
Do Until LockMe(guid) or t>15
t=DateDiff("s",start, Now())
Loop

'do stuff

UnLockMe

Function LockMe(pGuid)
if application("LockedBy") <"" then
LockMe=false
else
application.lock
if application("LockedBy") <"" then
LockMe=false
Application.Unlock
else
application("LockedBy") = pGuid
application.unlock
LockMe=true
end if
end if
End Function

Sub UnLockMe()
application.lock
application("LockedBy") = ""
application.unlock
End Sub
%>

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jun 22 '07 #5
deostroll wrote:
On Jun 22, 10:08 pm, "Bob Barrows [MVP]" <reb01...@NOyahoo.SPAMcom>
wrote:
>deostroll wrote:
>>Is there any way I can write a asp script such that if one user is
using it no other person can access that page until the processing
is complete...?
--deostroll

Oh wait, it's a little more complex than that. I will reply later
with a better reply if nobody beats me to it.
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so
I don't check it very often. If you must reply off-line, then remove
the "NO SPAM"

Hey bob, what if I just had a text file (locked.txt) that would read
either a 'yes' or 'no'. No in my asp code I could do some ordinary
file handling to access that text file. I can read the content of the
text file. If it reads 'no' then I can

a) truncate the text file and write yes into it, and
b) go on with the processing

or else give a message - "sorry this page is locked!!!"?
It's more complicated than that. What if another thread accesses the text
file before you save your change to it? The other thread will still see that
it says "no", change it to "yes" and go on its merry way.

You could utilize a GUID the way i did in my second example. Of course, with
text files, you need to worry about file-system permissions. Plus
performance: disk i/o is slower than accessing application variables.
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jun 22 '07 #6
On Jun 22, 10:49 pm, "Bob Barrows [MVP]" <reb01...@NOyahoo.SPAMcom>
wrote:
deostroll wrote:
On Jun 22, 10:08 pm, "Bob Barrows [MVP]" <reb01...@NOyahoo.SPAMcom>
wrote:
deostroll wrote:
Is there any way I can write a asp script such that if one user is
using it no other person can access that page until the processing
is complete...?
--deostroll
Oh wait, it's a little more complex than that. I will reply later
with a better reply if nobody beats me to it.
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so
I don't check it very often. If you must reply off-line, then remove
the "NO SPAM"
Hey bob, what if I just had a text file (locked.txt) that would read
either a 'yes' or 'no'. No in my asp code I could do some ordinary
file handling to access that text file. I can read the content of the
text file. If it reads 'no' then I can
a) truncate the text file and write yes into it, and
b) go on with the processing
or else give a message - "sorry this page is locked!!!"?

It's more complicated than that. What if another thread accesses the text
file before you save your change to it? The other thread will still see that
it says "no", change it to "yes" and go on its merry way.

You could utilize a GUID the way i did in my second example. Of course, with
text files, you need to worry about file-system permissions. Plus
performance: disk i/o is slower than accessing application variables.
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Thanx bob, that was some real help.

-deostroll

Jun 24 '07 #7

"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcomwrote in message
news:Ow**************@TK2MSFTNGP02.phx.gbl...
deostroll wrote:
Is there any way I can write a asp script such that if one user is
using it no other person can access that page until the processing is
complete...?
--deostroll

I think this will work better. I've incorporated a 15 second timeout - you
can adjust it to whatever fits your scalability needs:

<%
dim guid, TypeLib, start, t
'generate a unique id (GUID)
Set TypeLib = CreateObject("Scriptlet.TypeLib")
guid=Left(CStr(TypeLib.Guid), 38)

start=Now()
Do Until LockMe(guid) or t>15
t=DateDiff("s",start, Now())
Loop

'do stuff

UnLockMe

Function LockMe(pGuid)
if application("LockedBy") <"" then
LockMe=false
else
application.lock
if application("LockedBy") <"" then
LockMe=false
Application.Unlock
else
application("LockedBy") = pGuid
application.unlock
LockMe=true
end if
end if
End Function

Sub UnLockMe()
application.lock
application("LockedBy") = ""
application.unlock
End Sub
%>
Bob,

I'm not sure I understand why you're using a GUID? Session.SessionID or
some other ID that would help identify the user, client or session currently
locking for diagnostic purposes would be better.

Also after your code times out failing to get a lock the code goes on to to
it's stuff anyway.


Jun 26 '07 #8
Anthony Jones wrote:
"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcomwrote in message
news:Ow**************@TK2MSFTNGP02.phx.gbl...
>'generate a unique id (GUID)
Set TypeLib = CreateObject("Scriptlet.TypeLib")
guid=Left(CStr(TypeLib.Guid), 38)
Bob,

I'm not sure I understand why you're using a GUID? Session.SessionID
or some other ID that would help identify the user, client or session
currently locking for diagnostic purposes would be better.
>>
Not everyone uses sessions. GUIDs can be used whether sessions are enabled
or not.

I was just trying to create a generic solution, trusting that the OP would
be able to adapt it to his situation. To amplify:

If you're using sessions, and have taken precautions against
session-hijacking, use SessionID instead of Guid
If you are on a LAN or WAN, and your site has anonymous disabled and
Integrated autentication enabled, use the user's login name instead of the
GUID
If you are using Basic Authentication and your user logs into a database
that returns a unique user id, use the id instead of the GUID

>start=Now()
Do Until LockMe(guid) or t>15
t=DateDiff("s",start, Now())
Loop
'do stuff
<snip>
>
Also after your code times out failing to get a lock the code goes on
to to it's stuff anyway.
Oops ... er ... I left that as an exercise for the reader ... yeah, that's
the ticket!
Come on reader (not you, Anthony - I know you know the answer <grin>)! What
has to be changed in the above snippet to make it not go to the "do stuff"
part!

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jun 26 '07 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Paul Rohorzka | last post by:
Hi! I want a div to have width:10em if the content is narrow enough, but size it (not line-break), when the content will become longer. How can I do this? Thank you, Paul
2
by: Remco Groot Beumer | last post by:
Hello I've created an ASP.NET page, which uses some variables which are set after login. When person A logs in, a new public object is instanced (i'm not sure if that is a correct word), after...
5
by: Jason | last post by:
I am running Exchange 2003 on a Windows 2003 Active Directory. I am trying to mailbox-enable a user account with VB.NET. Dim person As CDO.Person Dim mailbox As CDOEXM.IMailboxStore person =...
26
by: Martin Jørgensen | last post by:
Hi, I don't understand these errors I get: g++ Persort.cpp Persort.cpp: In function 'int main()': Persort.cpp:43: error: name lookup of 'j' changed for new ISO 'for' scoping Persort.cpp:37:...
1
by: Jamie J. Begin | last post by:
I'm very new to the world of Python and am trying to wrap my head around it's OOP model. Much of my OOP experience comes from VB.Net, which is very different. Let's say I wanted to create an...
1
by: crystalgal | last post by:
Hello. I am tring to create a form that multi people use perhaps at the same time to enter daily counts for their production output. Scenario: There is 10 offices. I created 10 tables named after...
1
by: banging | last post by:
Hi there, I have a question regarding locking of tables so that when two or more people try to write or update the mysql tables, it locks up. Basically I only want one person to write to the...
16
by: weird0 | last post by:
How can a person become a C# MVP.. or say a complete MVP? What are the details: 1. What are the recommended books? 2. How many papers are there? 3. How to go about studying it? Where to do the...
3
by: mProgramz | last post by:
//Specification: This program plays a version of //the card game of 21. //A human player is pitted against the computer. //The player who is the closest to 21 without //going over wins the hand. ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.