Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / May 2008

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Hrvoje Vrbanc - 22 May 2008 13:06 GMT
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
Patrice - 22 May 2008 14:48 GMT
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" <hrvojev@recro.hr> a écrit dans le message de groupe de
discussion : #HlP$PAvIHA.5472@TK2MSFTNGP06.phx.gbl...
> Hello!
>
[quoted text clipped - 11 lines]
> Thank you in advance,
> Hrvoje
Hrvoje Vrbanc - 22 May 2008 15:21 GMT
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

> You can't do much more than polling either by :
>
[quoted text clipped - 27 lines]
>> Thank you in advance,
>> Hrvoje
bruce barker - 22 May 2008 16:12 GMT
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)

> Thank you Patrice.
>
[quoted text clipped - 49 lines]
> >> Thank you in advance,
> >> Hrvoje
Hrvoje Vrbanc - 22 May 2008 18:21 GMT
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

> web page do not keep a connection to the server, so there is no way for
> the
[quoted text clipped - 89 lines]
>> >> Thank you in advance,
>> >> Hrvoje
NH - 22 May 2008 16:04 GMT
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.

> Hello!
>
[quoted text clipped - 11 lines]
> Thank you in advance,
> Hrvoje

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.