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

Discussion in 'ASP .Net' started by Ben, Jun 7, 2006.

  1. Ben

    Ben Guest

    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
     
    Ben, Jun 7, 2006
    #1
    1. Advertising

  2. 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.

    --
    -Demetri


    "Ben" wrote:

    > 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
    >
    >
     
    =?Utf-8?B?RGVtZXRyaQ==?=, Jun 7, 2006
    #2
    1. Advertising

  3. Ben

    Guest

    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?).

    Demetri wrote:
    > 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.
    >
    > --
    > -Demetri
    >
    >
    > "Ben" wrote:
    >
    > > 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
    > >
    > >
     
    , Jun 7, 2006
    #3
  4. 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


    --
    Co-founder, Eggheadcafe.com developer portal:
    http://www.eggheadcafe.com
    UnBlog:
    http://petesbloggerama.blogspot.com




    "Ben" wrote:

    > 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
    >
    >
     
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=, Jun 7, 2006
    #4
  5. 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.
    --
    Regards

    John Timney (MVP)



    "Ben" <> wrote in message
    news:...
    > 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
    >
     
    John Timney \(MVP\), Jun 7, 2006
    #5
  6. Ben

    Ben Guest

    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

    wrote:
    > 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?).
    >
    > Demetri wrote:
    > > 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.
    > >
    > > --
    > > -Demetri
    > >
    > >
    > > "Ben" wrote:
    > >
    > > > 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
    > > >
    > > >
     
    Ben, Jun 7, 2006
    #6
  7. So use a transaction ...
    Ben wrote:
    > 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
    >
    > wrote:
    >> 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?).
    >>
    >> Demetri wrote:
    >>> 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.
    >>>
    >>> --
    >>> -Demetri
    >>>
    >>>
    >>> "Ben" wrote:
    >>>
    >>>> 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


    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.
     
    Bob Barrows [MVP], Jun 7, 2006
    #7
  8. 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.

    --
    -Demetri


    "John Timney (MVP)" wrote:

    > 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.
    > --
    > Regards
    >
    > John Timney (MVP)
    >
    >
    >
    > "Ben" <> wrote in message
    > news:...
    > > 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
    > >

    >
    >
    >
     
    =?Utf-8?B?RGVtZXRyaQ==?=, Jun 7, 2006
    #8
  9. Agreed,
    but in this case our OP is probably not at that level of experience yet. To
    be really efficient, you could offload the request into an MSMQ queue, and
    have a separate process retrieve the items from the queue and process them
    one - by - one.
    Peter

    --
    Co-founder, Eggheadcafe.com developer portal:
    http://www.eggheadcafe.com
    UnBlog:
    http://petesbloggerama.blogspot.com




    "Demetri" wrote:

    > 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.
    >
    > --
    > -Demetri
    >
    >
    > "John Timney (MVP)" wrote:
    >
    > > 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.
    > > --
    > > Regards
    > >
    > > John Timney (MVP)
    > >
    > >
    > >
    > > "Ben" <> wrote in message
    > > news:...
    > > > 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
    > > >

    > >
    > >
    > >
     
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=, Jun 7, 2006
    #9
  10. I agree with you Peter. Hence my somewhat simple suggestions.

    Regards

    John Timney (MVP)


    "Peter Bromberg [C# MVP]" <> wrote in message
    news:...
    > Agreed,
    > but in this case our OP is probably not at that level of experience yet.
    > To
    > be really efficient, you could offload the request into an MSMQ queue, and
    > have a separate process retrieve the items from the queue and process them
    > one - by - one.
    > Peter
    >
    > --
    > Co-founder, Eggheadcafe.com developer portal:
    > http://www.eggheadcafe.com
    > UnBlog:
    > http://petesbloggerama.blogspot.com
    >
    >
    >
    >
    > "Demetri" wrote:
    >
    >> 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.
    >>
    >> --
    >> -Demetri
    >>
    >>
    >> "John Timney (MVP)" wrote:
    >>
    >> > 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.
    >> > --
    >> > Regards
    >> >
    >> > John Timney (MVP)
    >> >
    >> >
    >> >
    >> > "Ben" <> wrote in message
    >> > news:...
    >> > > 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
    >> > >
    >> >
    >> >
    >> >
     
    John Timney \(MVP\), Jun 8, 2006
    #10
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    3
    Views:
    388
    Bruno Sirianni
    Apr 21, 2004
  2. Carlos
    Replies:
    4
    Views:
    11,572
    Alan Samet
    Sep 22, 2005
  3. Anan
    Replies:
    8
    Views:
    15,676
    John C. Bollinger
    Dec 8, 2004
  4. S_K
    Replies:
    18
    Views:
    712
    Larry Bud
    Oct 19, 2007
  5. Ryan Taylor
    Replies:
    1
    Views:
    692
    Ryan Taylor
    Sep 9, 2004
Loading...

Share This Page