在asp.net上推送更新 [英] push update on asp.net

查看:72
本文介绍了在asp.net上推送更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我打开了2页:add.aspx和view.aspx



add.aspx

- 用户将新记录添加到sql



view.aspx

- 显示来自sql的记录





目前我在view.aspx上使用更新面板和计时器,所以这个页面将连接到mysql并每隔10秒更新一次gridview。是的,这是一个非常糟糕的主意。



无论如何我可以改进这个功能吗?我希望view.aspx仅在add.aspx添加新记录时刷新。



我只需要一个想法/逻辑如何做到这一点。

assume i got 2 pages opened: "add.aspx" and "view.aspx"

add.aspx
- user add new record into sql

view.aspx
- show records from sql


currently im using update panel and timer at view.aspx, so this page will connect to mysql and update the gridview every 10 seconds. and yes, this is a very bad idea.

is there anyway that i can improve this features? i want the view.aspx is refresh ONLY when there is new record added from add.aspx.

I just need an idea/logic how this can be done.

推荐答案

你是对的,这是一个真正的问题。但这不是一个简单的问题,因为Web主要基于客户端 - 服务器模型,这意味着拉技术



请查看我过去的答案,了解一些背景和想法:应用程序'仪表板'对于网站帐户 [ ^ ]。



无论如何,如果你决定不争取服务器推送解决方案并选择传统的数据库轮询,我的其他过去的答案可以给出你知道如何减轻这些问题:使用计时器轮询数据库 [ ^ ]。



SA
You are right, this is a real problem. But this is not a simple problem, because Web is primarily based on client-server model, which means pull technology.

Please see my past answers for some background and ideas: Application 'dashboard' for website accounts[^].

Anyway, if you decide not to fight for server push solution and opt for traditional database polling, my other past answer can give you some idea how to suffer less from such problems: Polling Database with Timer[^].

—SA


为什么不在服务器端应用程序中创建一个int?

让我们说Application [UpdateID]为int。



当您插入或更新到数据库时,可以使用add.aspx递增它。

在view.aspx中,当Application [UpdateID时,您可以从db获取数据]已经改变。
Why not create an int in serverside Application?
Lets say Application["UpdateID"] as an int.

When you insert or update into database you can increment it with add.aspx.
In view.aspx you can get data from db when Application["UpdateID"] has changed.


这篇关于在asp.net上推送更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆