Force ASP.NET 2.0 page refresh when the database is updated

Discussion in 'ASP .Net' started by Hrvoje Vrbanc, May 22, 2008.

  1. Hello!

    I have an ASP.NET page that displays some data from an SQL Server 2005
    database, using a Select query. The database is updated by another piece of
    software, independently of the ASP.NET page. The ASP.NET page only displays
    data and it has nothing to do with inserting or updating data.

    What is the best way to force the refresh of the ASP.NET page every time a
    new record is inserted in the table?

    I tried to implement SQL Server cache dependency/invalidation but although
    the page returned no errors, I couldn't manage to make it refresh.

    Thank you in advance,
    Hrvoje
    Hrvoje Vrbanc, May 22, 2008
    #1
    1. Advertising

  2. Thank you Patrice.

    The content is very plain: first name, last name, company.
    Those records are added to a database table by another software, completely
    independent from web page.

    Web page shows those informations (SELECT TOP 1 * FROM tblUsers ORDER BY id
    DESC) by using a data reader and, as can be seen from the query, displays
    only the last record entered on a three label controls.

    Unfortunately, due to some other considerations, refreshing at a regular
    interval (even if it's a variable one by means of setting the timeout value
    in codebehind and then sending it to JacaScript) is not acceptable - I would
    really need the database to trigger the reload. The point is that reload
    should occur very quickly after the record insert and then the same
    informations should remain on screen until the next insert. I know it will
    stay so with periodical reloads as well but, to make a long story short, I
    can't use periodical reloads.

    Thank you,
    Hrvoje



    "Patrice" <http://www.chez.com/scribe/> wrote in message
    news:...
    > You can't do much more than polling either by :
    >
    > - refreshing at a regular interval (for example using setTimeOut client
    > side or a refresh meta tag)
    > - if this is costly you could perhaps issue an out of band call that will
    > just see if a refresh is needed and do the actual refresh based on the
    > result ?...
    >
    > Some more details about the exact context could also help...
    >
    > --
    > Patrice
    >
    > "Hrvoje Vrbanc" <> a écrit dans le message de groupe de
    > discussion : #HlP$...
    >> Hello!
    >>
    >> I have an ASP.NET page that displays some data from an SQL Server 2005
    >> database, using a Select query. The database is updated by another piece
    >> of software, independently of the ASP.NET page. The ASP.NET page only
    >> displays data and it has nothing to do with inserting or updating data.
    >>
    >> What is the best way to force the refresh of the ASP.NET page every time
    >> a new record is inserted in the table?
    >>
    >> I tried to implement SQL Server cache dependency/invalidation but
    >> although the page returned no errors, I couldn't manage to make it
    >> refresh.
    >>
    >> Thank you in advance,
    >> Hrvoje
    >>

    >
    Hrvoje Vrbanc, May 22, 2008
    #2
    1. Advertising

  3. Hrvoje Vrbanc

    NH Guest

    It is simple not possible to force a refresh like this because of the
    inherent nature of the web.

    The closest thing you can do is polling like the other person suggested.


    "Hrvoje Vrbanc" wrote:

    > Hello!
    >
    > I have an ASP.NET page that displays some data from an SQL Server 2005
    > database, using a Select query. The database is updated by another piece of
    > software, independently of the ASP.NET page. The ASP.NET page only displays
    > data and it has nothing to do with inserting or updating data.
    >
    > What is the best way to force the refresh of the ASP.NET page every time a
    > new record is inserted in the table?
    >
    > I tried to implement SQL Server cache dependency/invalidation but although
    > the page returned no errors, I couldn't manage to make it refresh.
    >
    > Thank you in advance,
    > Hrvoje
    >
    >
    >
    NH, May 22, 2008
    #3
  4. Hrvoje Vrbanc

    bruce barker Guest

    web page do not keep a connection to the server, so there is no way for the
    server to send a message to the client. the usual method is as suggested to
    have the client poll.

    to trigger a client event from the server requires a constant connection.
    there are three approaches for this

    1) use a java applet that open a socket to the server. the server can then
    notify the java applet, which can fire an event on the client.

    2) same as above but use a browser plugin.

    3) using a hidden frame and server push send events to the client. basically
    the client requests a page in a hidden frame, and the server push javascript
    to client in chucks via fluching. to do this with asp.net you need to up the
    page timeouts. also every couple a minutes, the client shoudl close and
    restablish the connection.

    all three of these approaches cause heavy resource load on the server. if
    you have too many clients, your server will run out of connections or process
    threads. you will need to tune this carefully.

    -- bruce (sqlwork.com)


    "Hrvoje Vrbanc" wrote:

    > Thank you Patrice.
    >
    > The content is very plain: first name, last name, company.
    > Those records are added to a database table by another software, completely
    > independent from web page.
    >
    > Web page shows those informations (SELECT TOP 1 * FROM tblUsers ORDER BY id
    > DESC) by using a data reader and, as can be seen from the query, displays
    > only the last record entered on a three label controls.
    >
    > Unfortunately, due to some other considerations, refreshing at a regular
    > interval (even if it's a variable one by means of setting the timeout value
    > in codebehind and then sending it to JacaScript) is not acceptable - I would
    > really need the database to trigger the reload. The point is that reload
    > should occur very quickly after the record insert and then the same
    > informations should remain on screen until the next insert. I know it will
    > stay so with periodical reloads as well but, to make a long story short, I
    > can't use periodical reloads.
    >
    > Thank you,
    > Hrvoje
    >
    >
    >
    > "Patrice" <http://www.chez.com/scribe/> wrote in message
    > news:...
    > > You can't do much more than polling either by :
    > >
    > > - refreshing at a regular interval (for example using setTimeOut client
    > > side or a refresh meta tag)
    > > - if this is costly you could perhaps issue an out of band call that will
    > > just see if a refresh is needed and do the actual refresh based on the
    > > result ?...
    > >
    > > Some more details about the exact context could also help...
    > >
    > > --
    > > Patrice
    > >
    > > "Hrvoje Vrbanc" <> a écrit dans le message de groupe de
    > > discussion : #HlP$...
    > >> Hello!
    > >>
    > >> I have an ASP.NET page that displays some data from an SQL Server 2005
    > >> database, using a Select query. The database is updated by another piece
    > >> of software, independently of the ASP.NET page. The ASP.NET page only
    > >> displays data and it has nothing to do with inserting or updating data.
    > >>
    > >> What is the best way to force the refresh of the ASP.NET page every time
    > >> a new record is inserted in the table?
    > >>
    > >> I tried to implement SQL Server cache dependency/invalidation but
    > >> although the page returned no errors, I couldn't manage to make it
    > >> refresh.
    > >>
    > >> Thank you in advance,
    > >> Hrvoje
    > >>

    > >

    >
    >
    >
    bruce barker, May 22, 2008
    #4
  5. I solved the problem by embedding a zero-width and height iFrame on the main
    page. The codebehind of the page within the iFrame is refreshed every 1
    second and when it notices a new record had been added to the DB table, it
    refreshes the parent page with parent.location.reload(). Works good!

    Hrvoje




    "bruce barker" <> wrote in message
    news:...
    > web page do not keep a connection to the server, so there is no way for
    > the
    > server to send a message to the client. the usual method is as suggested
    > to
    > have the client poll.
    >
    > to trigger a client event from the server requires a constant connection.
    > there are three approaches for this
    >
    > 1) use a java applet that open a socket to the server. the server can then
    > notify the java applet, which can fire an event on the client.
    >
    > 2) same as above but use a browser plugin.
    >
    > 3) using a hidden frame and server push send events to the client.
    > basically
    > the client requests a page in a hidden frame, and the server push
    > javascript
    > to client in chucks via fluching. to do this with asp.net you need to up
    > the
    > page timeouts. also every couple a minutes, the client shoudl close and
    > restablish the connection.
    >
    > all three of these approaches cause heavy resource load on the server. if
    > you have too many clients, your server will run out of connections or
    > process
    > threads. you will need to tune this carefully.
    >
    > -- bruce (sqlwork.com)
    >
    >
    > "Hrvoje Vrbanc" wrote:
    >
    >> Thank you Patrice.
    >>
    >> The content is very plain: first name, last name, company.
    >> Those records are added to a database table by another software,
    >> completely
    >> independent from web page.
    >>
    >> Web page shows those informations (SELECT TOP 1 * FROM tblUsers ORDER BY
    >> id
    >> DESC) by using a data reader and, as can be seen from the query, displays
    >> only the last record entered on a three label controls.
    >>
    >> Unfortunately, due to some other considerations, refreshing at a regular
    >> interval (even if it's a variable one by means of setting the timeout
    >> value
    >> in codebehind and then sending it to JacaScript) is not acceptable - I
    >> would
    >> really need the database to trigger the reload. The point is that reload
    >> should occur very quickly after the record insert and then the same
    >> informations should remain on screen until the next insert. I know it
    >> will
    >> stay so with periodical reloads as well but, to make a long story short,
    >> I
    >> can't use periodical reloads.
    >>
    >> Thank you,
    >> Hrvoje
    >>
    >>
    >>
    >> "Patrice" <http://www.chez.com/scribe/> wrote in message
    >> news:...
    >> > You can't do much more than polling either by :
    >> >
    >> > - refreshing at a regular interval (for example using setTimeOut client
    >> > side or a refresh meta tag)
    >> > - if this is costly you could perhaps issue an out of band call that
    >> > will
    >> > just see if a refresh is needed and do the actual refresh based on the
    >> > result ?...
    >> >
    >> > Some more details about the exact context could also help...
    >> >
    >> > --
    >> > Patrice
    >> >
    >> > "Hrvoje Vrbanc" <> a écrit dans le message de groupe de
    >> > discussion : #HlP$...
    >> >> Hello!
    >> >>
    >> >> I have an ASP.NET page that displays some data from an SQL Server 2005
    >> >> database, using a Select query. The database is updated by another
    >> >> piece
    >> >> of software, independently of the ASP.NET page. The ASP.NET page only
    >> >> displays data and it has nothing to do with inserting or updating
    >> >> data.
    >> >>
    >> >> What is the best way to force the refresh of the ASP.NET page every
    >> >> time
    >> >> a new record is inserted in the table?
    >> >>
    >> >> I tried to implement SQL Server cache dependency/invalidation but
    >> >> although the page returned no errors, I couldn't manage to make it
    >> >> refresh.
    >> >>
    >> >> Thank you in advance,
    >> >> Hrvoje
    >> >>
    >> >

    >>
    >>
    >>
    Hrvoje Vrbanc, May 22, 2008
    #5
    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. =?Utf-8?B?U1M=?=
    Replies:
    3
    Views:
    3,808
    Juan T. Llibre
    May 15, 2005
  2. =?Utf-8?B?bG9uZG9uIGNhbGxpbmc=?=

    force asp.net to remove cached page literals asp.net 1.1

    =?Utf-8?B?bG9uZG9uIGNhbGxpbmc=?=, Jul 4, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    532
    =?Utf-8?B?bG9uZG9uIGNhbGxpbmc=?=
    Jul 5, 2005
  3. Replies:
    4
    Views:
    593
  4. Catherina Svensson
    Replies:
    0
    Views:
    366
    Catherina Svensson
    May 18, 2008
  5. Dmitry Korolyov

    Datagrid not updated during delete, but updated during insert and update

    Dmitry Korolyov, Sep 22, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    400
    Dmitry Korolyov
    Sep 22, 2003
Loading...

Share This Page