Silverlight, SignalR and IIS Applications off of t

2019-02-19 03:23发布

I'm using SignalR in a Silverlight 5 application. When I host my app in an "application" off of the default website in IIS 7.5 (i.e. localhost/subsite) Fiddler shows I get a 404 for "/signalr/negotiate".

It doesn't seem to take the IIS application path into account. It should be requesting "/subsite/signalr/negotiate". How do I get it to use the correct url prefix?

Update: I had to use the following code because it seems to be difficult to get the real root URI in a silverlight app without doing some parsing.

string xapLocationUri = Application.Current.Host.Source.AbsoluteUri;  

string rootUri = xapLocationUri.Substring(0, xapLocationUri.IndexOf("/ClientBin"));  

hubConnection = new HubConnection(rootUri);  

You can't really rely on the following if you're hosted in an application off of the root web site in IIS:

Application.Current.Host.Source.GetComponents(UriComponents.Scheme | UriComponents.HostAndPort, UriFormat.Unescaped)  

0条回答
登录 后发表回答