简体   繁体   中英

Best practice for sharing data between a WCF service and a web site

I have a .net web page which displays a list of objects. I also have a WCF service which allows clients to submit new objects. This is all glued together via SQL Server.

My question is: I would like to have the page update asynchronously when a new object is inserted via the service. Can you suggest a best practice for doing this? I would like to avoid polling the database, and the service and page don't seem to share a Cache.

Thanks!

The best practice is to use the persistent store (aka database) for this kind of thing.

The SOA world is advocating statelessness - your WCF service shouldn't have to keep some state anywhere, other than in the persistent store designed for that - the database.

Using the database, you could easily set up a "change notification" from the database, so that your page gets notified when its underlying data has changed, so it can update itself. Search for SQL Server Change Notification and you should find lots of samples and tutorials on how to do that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM