How can I send a trigger to a client when a record request is posted on the database server?
I need to develop an application that can address the following: Customers will request recording of some programs on tape. So the request is saved on a database (actually, it is an Access database, but we are planning for SQL Server at a later stage). The employees are opening a dynamic Web page containing the recording information.
I want this to happen: Whenever a record request is posted, a trigger is sent to the client and an update on the employee Web page is done without refresh.
Can you please tell me what should be done on the employees' side and on the server side?
When you register, you'll begin receiving targeted emails from my team of award-winning writers. Our goal is to provide a unique online resource for developers, architects and development managers tasked with building and maintaining enterprise applications using Visual Basic, C# and the Microsoft .NET platform.
Hannah Smalltree, Editorial Director
By the very nature of the Web and browsers, what you want to do isn't possible. There's no connection between the server and the client once a specific request has been satisfied. The server returns a response and forgets about the client. There's nothing you can do about that. This functionality is possible only for desktop apps. One workaround is to implement a background polling mechanism in the client-side by using JavaScript and the XmlHttpRequest object. With it, you can post a query to the server for information about changes. If you get new data in the response through the XmlHttpRequest, you can update the page view directly with DHTML from the JavaScript. This means the user will not see a page refresh.
On the server-side, you can either create an empty aspx form that processes these specific kind of posts, or you can create a custom IhttpHandler implementation, associate it with a new 'file' extension and process everything inside it. This is the most professional and reusable approach.
However, implementing this feature increases network traffic, so you have to evaluate its benefits carefully.
Dig Deeper
-
People who read this also read...
This was first published in June 2003