简体   繁体   English

带有MVC的自托管SignalR

[英]Self hosted SignalR with MVC

Is it possible to use a self hosted signalR server with an MVC(4) application such that it is totally seperate from the signalR server? 是否可以使用带有MVC(4)应用程序的自托管signalR服务器,使其完全独立于signalR服务器?

I tried Tim and Patrick's beautifully executed SignalR intro tutorial , and was wondering if I could try that? 我尝试了蒂姆和帕特里克精美的SignalR简介教程 ,并想知道我是否可以尝试一下? And even if I could, would that offer any performance advantages over an integrated service as is metioned in the tutorial. 即使我可以,这也会提供比本教程中提到的集成服务更多的性能优势。

It is absolutely possible to self-host a SignalR 2.0 server with OWIN and accessing this server from within any Website (which may be a MVC application). 绝对有可能使用OWIN自行托管SignalR 2.0服务器并从任何网站(可能是MVC应用程序)访问此服务器。 The only thing you need is to enable CORS (app.UseCors(CorsOptions.AllowAll); in your Startup file of the Owin Host) since it's not on the same domain as your Website. 您唯一需要的是启用CORS(app.UseCors(CorsOptions.AllowAll);在Owin主机的启动文件中),因为它与您的网站不在同一个域中。 Obviously you can't use SignalR within the MVC application itself this way (eg to publish messages). 显然,你不能以这种方式在MVC应用程序中使用SignalR(例如发布消息)。

I'm using a self-hosted ASP.NET Web API 2 and SignalR 2 server with OWIN to serve data to clients. 我正在使用自托管的ASP.NET Web API 2和带有OWIN的SignalR 2服务器来向客户端提供数据。 You can find an example server using this scenario here . 您可以在此处找到使用此方案的示例服务器。 Tho advantage in this approach is to have your views & styles sepparated from your data and business logic. 这种方法的优点是可以从数据和业务逻辑中分离出您的视图和样式。 Making everything very easy to cache and scale. 使一切都很容易缓存和扩展。

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

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