如何在asp网站上创建notificatin [英] how to create notificatin in asp website

查看:100
本文介绍了如何在asp网站上创建notificatin的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述






我想创建通知。就像在Facebook上看到的新朋友请求一样。有计数。任何人都建议我任何链接..





提前感谢..

Hi

I want to create Notification like. Just like a new friend request seen in facebook. with an count. any one suggest me any link..


thanks in advance..

推荐答案

你可以使用SignalR。



使用ASP.NET SignalR发送通知

使用SignalR的实时通知
You can use SignalR.

Sending Notifications using ASP.NET SignalR
Real-time Notifications with SignalR


如果你想按照旧的和简单的实现检查以下代码:

if you want to follow Old and simple implementation check following code:
setInterval(function() {
  // Call your webmethod here using jquery ajax and refresh notification section
}, 5000);



让我们看看一些已知的技术在服务器上发生更改时刷新当前页面或页面的某些部分:

定期页面刷新:这是显而易见的因为所有页面都被刷新,所以这是最糟糕的方法。不幸的是,它仍然在一些新闻门户网站上使用。



定期刷新页面中的部分:在这种方法中,我们定期AJAX向服务器请求并使用传入数据刷新页面的一部分。这通常使用ASP.NET Web窗体中的UpdatePanel和Timer实现。只有在节数据发生变化时,才能对此方法进行改进。此方法也很糟糕且不可扩展,因为即使服务器上没有新数据,我们也会通过定期请求使服务器忙碌。此外,它不是实时通知,因为我们定期而非连续地提出请求。



长轮询:这是使用的方法通过SignalR。我们向服务器发出请求,但在服务器上有新数据之前不会收到响应。因此,如果服务器上没有新信息,客户端和服务器就会等待,不执行任何操作,因此服务器不忙。



WebSockets:HTML5自带websockets API。它允许我们在客户端和服务器之间创建持久连接,因此,服务器和客户端可以异步地相互发送数据。这是一个更高级别的TCP连接。这将是不久的将来在网络上进行异步通信的标准方式。但是,就目前而言,并非每个浏览器都完全实现了它。正如我读过但尚未尝试过的,SignalR也支持WebSockets。所以,您现在可以使用SignalR并在将来更改传输层。


Let's see some known techniques to refresh current page or some parts of the page upon changes on the server:
Periodic page refresh: This is obviously the worst method since all pages are refreshed. Unfortunately, it is still used on some news portals.

Periodic refreshing of a section in the page: In this method, we make periodic AJAX requests to the server and refresh a part of page with incoming data. This is generally implemented using UpdatePanel and Timer in ASP.NET Web Forms. An improvement to this method can be refreshing the section only if the section data changes. This method is also bad and not scalable since we make the server busy by making periodic requests even when no new data is available on the server. Also, it's not a real time notification since we make requests periodically, not continuously.

Long polling: This is the method that is used by SignalR. We make a request to the server but not receive response until a new data available on the server. Thus, if no new information is available on the server, client and server will just wait, no operation is performed, thus server is not busy

WebSockets: HTML5 comes with websockets API. It allows us to create persistent connections between client and server, thus, server and client can send data to each other asynchronously. It's a higher level TCP connection. This will be the standard way of asynchronous communication on the web in the near future. But, for now, not every browser fully implemented it. As I read but not tried yet, SignalR also has WebSockets support. So, you can use SignalR now and change transport layer in the future.


您好,



Ref:如何制作像facebook这样的通知


这篇关于如何在asp网站上创建notificatin的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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