简体   繁体   English

C#.NET Web应用程序Web窗体消息其他Web窗体上的数据已更改

[英]C# .NET web application Web Form message other Web Form on data changed

Alright, here's my situation. 好吧,这是我的情况。 I've been looking on the internet but I can't find anything to tackle this problem. 我一直在寻找互联网,但找不到任何解决此问题的方法。

I got two different Web applications in C# .NET. 我在C#.NET中得到了两个不同的Web应用程序。 The first one (Let's call it application A) is to create, insert, update and delete data to the database. 第一个(我们称之为应用程序A)是创建,插入,更新和删除数据库中的数据。 And the second one (Application B) is just to display information on a screen from the database but it can update a few small things on it's own, the single page is divided in different sections with each an update panel because certain things need to update more often than others. 第二个(应用程序B)只是在数据库的屏幕上显示信息,但是它可以自己更新一些小东西,单个页面分为不同的部分,每个页面都有一个更新面板,因为某些东西需要更新比其他人更多。

What I want is, if application A changes any data to the database, I want applicaiton B to update its update panels, so I want application A to send a message of some kind to application B. Currently the updatepanels update every x seconds which is horrible for the servers. 我想要的是,如果应用程序A将任何数据更改到数据库,我希望应用程序B更新其更新面板,因此我希望应用程序A向应用程序B发送某种消息。当前,更新面板每隔x秒更新一次,即服务器太可怕了。

Note that application B can have different clients, which each having their own unique data. 请注意,应用程序B可以具有不同的客户端,每个客户端都有自己的唯一数据。

Does anyone have an idea of how to tackle this problem and what techniques can be used for this? 有谁知道如何解决这个问题以及可以使用哪些技术?

Normally, for the web, the server doesn't do anything until the client asks it to. 通常,对于Web而言,服务器不会执行任何操作,直到客户端要求。 In this case, it's not the client that's asking, it's another server. 在这种情况下,不是客户端在问,而是另一台服务器。 If you want Application B to update the client without the client asking for it, you're going to have to do a WebSocket or some other push system between Application B and its client. 如果您希望应用程序B在客户端不要求客户端的情况下更新客户端,则必须在应用程序B及其客户端之间执行WebSocket或其他推送系统。

To send data from Application A to Application B, you'll need to use one of a couple different IPC (interprocess communication) tools. 要将数据从应用程序A发送到应用程序B,您将需要使用几个不同的IPC(进程间通信)工具之一。 The easiest would probably be to set up a UDP or a TCP socket between Application A and Application B. 最简单的方法可能是在应用程序A和应用程序B之间设置UDP或TCP套接字。

how about a CORS request ? CORS要求如何?

write an AJAX call to the App B from App A such that whenever the update process complete it should send the call (you can us Webmethod of course for achieving this) and in the application B you can update the Panel from the function 从应用程序A向应用程序B写一个AJAX调用,这样,只要更新过程完成,它就应该发送该调用(您当然可以使用Web方法来实现此功能),并且在应用程序B中可以从该功能更新面板

SqlDependency是一个特殊的.NET类,它使您可以订阅事件,随后,订阅的命令可从https://msdn.microsoft.com/zh-cn/library/62xk7953(v=vs.110).aspx从SQLServer获取通知

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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