Click here to Skip to main content
15,893,904 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hello All,

I have one project in that I have to Refresh the data in ASP project by using WCF.without pooling .Can any one help me for that please.

Regards,
Manish
Posted

1 solution

XML
I'd like to help you answering this, but unfortunately there is no straight cut mechanism to implement your requirement.

See, this is easy to implement in a desktop based application using the SqlDependency of ADO.NET 2.0 and you don't have to use polling. In your application you will get notification from the SQL Server when any data changes and you just display the updated data in your desktop UI. I saw this article <a href="http://www.codeproject.com/KB/database/chatter.aspx">Using SqlDependency for data change events</a>[<a href="http://www.codeproject.com/KB/database/chatter.aspx" target="_blank" title="New Window">^</a>] which uses SqlDependency for capturing data change events  and showing in the UI.

Unfortunately, web applications does not work in this way. Using SQL Server's change notification service in Asp.net, you will get the notification in your application (See <a href="http://aspalliance.com">http://aspalliance.com</a>[<a href="http://aspalliance.com" target="_blank" title="New Window">^</a>]). But, how would you display the updated data in the browser(s)?

A fundamental difference between the desktop and web application is that, the desktop application has only one client, and that runs within the same CLR where the application is running. So, it can display the updated data instantly in the output. But, a web application can have unlimited number of clients (Browsers) which run on different machines.  It would have been really nice if the server application could send (Broadcast) all of the clients (browsers) the updated data to show in the browser immediately, but conventionally, web applications does not work in this way. Http protocol is stateless and a web application can only respond to a browser only if it gets a request from the browser. Once a request arrives, the web application processes it, sends response and simply forgets. So, when the application running at the server has an updated data from the database server, it can't send it to the clients immediately, unless it gets request from them (Browsers).

Well, that's not the 100% story. These days, people have started to implement HTTP Push (Or, Comet) that uses a persistent connection to broadcast data from the server to the clients. Usually, the web based chat applications use this technique. See <a href="http://www.codeproject.com/KB/aspnet/wxv_comet.aspx">ASP.NET and Comet: Bringing Sockets Back</a>[<a href="http://www.codeproject.com/KB/aspnet/wxv_comet.aspx" target="_blank" title="New Window">^</a>] that discusses a simple Comet implementation.

Unfortunately, this has it's drawback too. Javascript cannot do socket level communication and hence, some workaround has to be done for these kinds of implementations (Using flash or Silverlight). If the client application is a RIA implementation (Rich Internet Application, using Flash or Silverlight), it becomes easier to implement the Comet (See <a href="http://weblogs.asp.net/dwahlin/archive/2008/06/16/pushing-data-to-a-silverlight-client-with-wcf-duplex-service-part-i.aspx">http://weblogs.asp.net/dwahlin/archive/2008/06/16/pushing-data-to-a-silverlight-client-with-wcf-duplex-service-part-i.aspx</a>[<a href="http://weblogs.asp.net/dwahlin/archive/2008/06/16/pushing-data-to-a-silverlight-client-with-wcf-duplex-service-part-i.aspx" target="_blank" title="New Window">^</a>]). But, if the client is a plain XHTML browser application, a hidden Flash or Silverlight application has to be used for doing secret communication with the Server.

I hope, this will help you getting your answer. Best of luck.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900