Orchard CMS 中的 SignalR 聊天模块

发布于 2024-12-29 18:24:00 字数 8 浏览 1 评论 0原文

continue

I am building an instant chat module for the orchard project I am working on. I would like to use SignalR to power the chat, however I am running into difficulties with this:

<script src="@Url.Content("~/signalr/hubs")" type="text/javascript"></script>

I receive 404 error with everything I try. I have RAMFAR in webconfig, I have tried rewritting the url on IIS. I am hoping it is something horribly simple that my addled brain cant quite see. I don't even know for sure that SignalR works with Orchard, I suspected there would be some difficulties though

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

烟雨扶苏 2025-01-05 18:24:00

It's much more tricky than @mdm described... SignalR uses a custom HttpModule that handles hubs. Unfortunately, due to dynamic loading of module assemblies there is no way to wire that HttpModule from a module without altering Orchard core.

Fortunately, I managed to sort things out and made a live demo with Orchard and SignalR playing nice together! Making it work was quite tricky and involved dropping the HttpModule in favor of a custom route implementation. I'll push the module to Orchard Gallery after doing some necessary cleanup and post an update here.

UPDATE: Module is nearly finished. There was a lot of changes in SignalR library since I started so needed to incorporate those.另外,Orchard 核心(会话处理)有一个细微的变化,我需要在实际发布模块之前推送它。

更新 2: SignalR 现在使用 Owin,因此连接所有内容要容易得多。 Orchard 模块位于此处。您还可以从 BitBucket 获取最新代码
顺便说一句,由于数据库事务处理发生了变化,我强烈建议使用 Orchard 1.x 分支中的代码进行 SignalR 开发。

It's much more tricky than @mdm described... SignalR uses a custom HttpModule that handles hubs. Unfortunately, due to dynamic loading of module assemblies there is no way to wire that HttpModule from a module without altering Orchard core.

Fortunately, I managed to sort things out and made a live demo with Orchard and SignalR playing nice together! Making it work was quite tricky and involved dropping the HttpModule in favor of a custom route implementation. I'll push the module to Orchard Gallery after doing some necessary cleanup and post an update here.

UPDATE: Module is nearly finished. There was a lot of changes in SignalR library since I started so needed to incorporate those. Also, there is one slight change to Orchard core (session handling) that I need to push before actually publishing the module.

UPDATE 2: SignalR uses Owin now so it's much easier to wire everything up. Orchard module is available here. You can also grab the latest code from BitBucket.
Btw, I highly recommend using code from Orchard 1.x branch for SignalR development due to database transaction handling changes.

美人迟暮 2025-01-05 18:24:00

continue

What is the URL that gets output on the page? What URL do you expect it to show?

Usually you would put the SignalR code in Scripts/signalr and reference scripts with the following at the top of your view:

@{
    Script.Include("signalr/script.js");
}

Or you could implement an IResourceManifestProvider in your module (Orchard.jQuery has a fantastic example of this, or see here), and then reference your scripts using Script.Require:

@{
    Script.Require("SignalR_Hubs");
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文