英文:
Can I use signalr with Asp .Net (not ASP. Net core)?
问题 {#heading}
我对SignalR是否可以在ASP.NET(而非ASP.NET Core)上运行感到困惑。我正在使用ASP.NET构建一个项目,但找不到任何资源或示例提到SignalR可以在ASP.NET上运行,而在这个项目中页面会频繁进行页面回发。
我觉得这个问题有点愚蠢...但我真的很困惑...
请帮助我一下,如果可以工作的话,请引导我到一些教程...
我在YouTube和Google上搜索以确认或找到示例,但没有成功... 英文:
I am confused about SignalR if it can work on asp.net (not asp. Net core). I am building a project in ASP.NET but cannot find any resource or example that mention that SignalR can works on Asp. Net in which pages work heavily on Page Postback.
I feel the question little bit stupid.. But i am really confused...
Please give me a hand, and if Yes, it is working, please lead me to some tutorials..
I searched youtube and google to confirm or find an example but there was no luck...
答案1 {#1}
得分: 1
是的,您可以在ASP.NET(不是ASP.NET Core)中使用SignalR。SignalR最初是作为ASP.NET的一部分引入的,后来为ASP.NET Core提供了一个单独的版本。然而,SignalR的原始ASP.NET版本现在被称为"SignalR for ASP.NET"或有时称为"SignalR 2.x"。
-
安装SignalR包:使用NuGet包管理器控制台安装ASP.NET的SignalR包:
-
配置SignalR:在您的ASP.NET应用程序的Startup或Global.asax文件中,您需要在Application_Start方法中配置SignalR:
-
创建Hubs:通过继承Microsoft.AspNet.SignalR.Hub来创建SignalR hubs:
-
客户端代码:在客户端使用jquery.signalR.js脚本与SignalR hubs进行交互:
-
HTML标记:添加HTML标记以与hub进行交互:
-
JavaScript交互:使用JavaScript处理与hub的交互:
英文:
Yes, you can use SignalR with ASP.NET (not ASP.NET Core). SignalR was originally introduced as part of ASP.NET and later got a separate version for ASP.NET Core. However, the original ASP.NET version of SignalR is now referred to as "SignalR for ASP.NET" or sometimes "SignalR 2.x".
-
Install SignalR Package: Install the SignalR package for ASP.NET
using NuGet Package Manager Console: -
Configure SignalR: In your ASP.NET application's Startup or
Global.asax file, you need to configure SignalR in the
Application_Start method: -
Create Hubs: Create SignalR hubs by inheriting from
Microsoft.AspNet.SignalR.Hub: -
Client-Side Code: Use the jquery.signalR.js script on the client side
to interact with SignalR hubs: -
HTML Markup: Add HTML markup to interact with the hub:
-
JavaScript Interaction: Use JavaScript to handle interactions with
the hub: