2012-02-19 65 views
0

沒有發現我有下面的服務器代碼:入門404使用SignalR.Hosting.Self

var server = new Server("http://localhost:13170/"); 
server.MapConnection<EchoConnection>("echo"); 
server.Start(); 

但是,當我連接到它從我的客戶端代碼:

var connection = new Connection("http://localhost:13170/echo"); 
connection 
    .Start() 
    .ContinueWith(t => 
        { 
         if (!t.IsFaulted) 
          connection.Send("Hello"); 
         else 
          Console.WriteLine(t.Exception); 
        }); 

...它報告:

System.Net.WebException: The remote server returned an error: (404) Not Found. 

我做錯了什麼?

回答

2

原來的參數MapConnection必須以斜線開頭:

server.MapConnection<EchoConnection>("/echo"); 

這是因爲Server.ResolvePath預先考慮查找在映射的URL前斜線。

+0

高興你理解了它。 – davidfowl 2012-02-20 06:20:03