How to modify the SignalR Hub URL

两盒软妹~` 提交于 2019-12-06 07:01:34

问题


I would like to use a different base hub URL than ~/signalr/hubs. How to modify this url, for example to ~/api/hubs?

Second question, may I use a different url for a different sets of hubs? For example:

~/api/chat/hubs  
~/api/email/hubs

Thanks.


回答1:


Ran across this, possible now with 0.5+:

RouteTable.Routes.MapHubs("~/api");



回答2:


  1. No you may not, it's hardcoded in the source.
  2. No the proxy generated is for all hubs.



回答3:


Well this question is old (4 years? wtf.. I always thought web sockets was kinda new).

... Well they(Microsoft) have new descriptive well written documentation on their website now

This could be a link only answer but if you are in a hurry.... On the server side at the startup or owin app config have somthing like this...

app.MapSignalR("/newCoolUrl", new HubConfiguration());

Ehhh sure you need to replace everything "/signalr" on whichever clients you are using to "/newCoolUrl" example

var connection = $.hubConnection("/newCoolUrl", { useDefaultPath: false });


来源:https://stackoverflow.com/questions/8141410/how-to-modify-the-signalr-hub-url

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!