How to allow only one user to access a web page at one time?

B

Ben

Hi,

In ASP.NET website, I have a web page is used to dump raw data into
database (SQL Server). The database data will corrupt if two users
dump raw data concurrently.
How to allow only one user to access a web page at one time?

Thanks,
Ben
 
G

Guest

I think you are looking at this all wrong. Its not the page that is the
concern its the data input. Therefore, I would implement some sort of
asynchronous input of data ( queue if you will). This way users can come and
dump data all day long at the same time but your system will only do one at a
time.
 
S

sdbillsfan

That doesn't make any sense though, SQL Server (as with all RDBMS') is
perfectly capable of inherently handling concurrent DML without
corruption. I have the feeling the problem is somewhere else (DAL
perhaps?).
 
G

Guest

I agree with Dimitry, but essentially all you need to do is set an
Application variable
Application["InUse"]=true while the dump operation is going and set it back
to
Application["InUse"]=false when it is done.
For all requests to the page, in the Page_Load handler,
if( Convert.ToBoolean(Application["InUse"])
Response.End();

That should pretty much cover it very simply.

Peter
 
J

John Timney \(MVP\)

An easy solution would be to limit access to only one named user in
web.configs location tag. But to limit it to one random user - instead of
limiting access to a page, check if the SQL statement is running by setting
a simple flag in the DB and checkings its value before running the data
dump. If it is reject the request.
 
B

Ben

Thanks for all the replies.

The raw data is in excel format. Actually, it is not just dumping.
There are a lot of deleting, updating, inserting and verifications on
database records. So it is not a single Query or stored procedure. Each
record is processed in ASP page by loop.

Ben
 
B

Bob Barrows [MVP]

So use a transaction ...
Ben said:
Thanks for all the replies.

The raw data is in excel format. Actually, it is not just dumping.
There are a lot of deleting, updating, inserting and verifications on
database records. So it is not a single Query or stored procedure.
Each record is processed in ASP page by loop.

Ben
 
G

Guest

I wouldn't want to reject the request and have the user re-submit a bunch of
times in a row until it goes through. That is not a good user experience.
Again, a queue of some sort to manage the input one at a time in an
asynchronous fashion is more sound in my eyes.
 
J

John Timney \(MVP\)

I agree with you Peter. Hence my somewhat simple suggestions.

Regards

John Timney (MVP)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top