问题
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:
- No you may not, it's hardcoded in the source.
- 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