URL path changes between dev and published version
- by Bob Horn
I just got Scott Hanselman's chat app with SignalR working with ASP.NET MVC 4. After hours of configuration, trial and error, and getting different versions of Windows to talk to each other on my home network, it's all working except that I'm left with one issue that I'm not sure how to handle.
This line of javascript has to change, depending on if I'm running the app through Visual Studio or the published (IIS) version:
Works when running within VS:
var connection = $.connection('echo');
Works with published version:
var connection = $.connection('ChatWithSignalR/echo');
When I run within VS, the URL is:
http://localhost:9145/
And the published version is:
http://localhost/ChatWithSignalR
If I don't change that line of code, and try to run the app within VS, using the javascript that has ChatWithSignalR in it, I get an error like this:
Failed to load resource: the server responded with a status of 404 (Not Found)
http://localhost:9145/ChatWithSignalR/echo/negotiate?_=1347809290826
What can I do so that I can use the same javascript code and have it work in both scenarios?
var connection = $.connection('??????');
Note, this is in my Global.asax.cs:
RouteTable.Routes.MapConnection<MyConnection>("echo", "echo/{*operation}");