Bir sohbet uygulaması uygulamak için signalr
kullanıyorum.
Winform istemcisindeki bağlantı başlatılamıyor
`An exception of type 'Microsoft.AspNet.SignalR.Client.HttpClientException'
occurred in mscorlib.dll but was not handled in user code
Additional information: StatusCode: 500, ReasonPhrase: 'Internal Server Error', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
Date: Fri, 21 Aug 2015 07:22:52 GMT
Server: Microsoft-HTTPAPI/2.0
Content-Length: 0
}
ben nedenini bilmiyorum:
Ancak, aşağıdaki hatayı alıyorum. Ben signalR sürüm 2.2.0 kullanıyorum İşte benim Hub İşte
class ChatHub : Hub
{
public void Send(string message)
{
Clients.All.addMessage(message);
}
public override Task OnConnected()
{
Console.WriteLine("Client connected: " + Context.ConnectionId);
return base.OnConnected();
}
}
olduğunu benim Startup class
class Startup
{
public void Configuration(IAppBuilder app)
{
app.UseCors(CorsOptions.AllowAll);
app.MapSignalR();
}
}
Benim Sunucu Programı
class Program
{
const string url = "http://localhost:8080";
static void Main(string[] args)
{
WebApp.Start(url);
Console.WriteLine("Started server at " + url);
Console.ReadLine();
}
}
istemci winform
Benim işlevi
private async void AsyncConnect()
{
Connection = new HubConnection(url);
chatProxy = Connection.CreateHubProxy("ChatHub");
chatProxy.On<string>("addMessage", message =>
txtMessageShow.Text += message + Environment.NewLine);
await Connection.Start();
}
'Connection' ve' chatProxy' için ne tür bir özellik veriyorsunuz? Ayrıca, 'url' içerir? Bir fom 'const string url' ile aynı mı? –
"HubConnection bağlantısı", "IHubProxy chatProxy" ve url, const dizesi url = "http: // localhost: 8080" ' – KlynkC
atayım. Öncelikle, C# büyük/küçük harfe duyarlıdır; Bağlantı ve bağlantı. İkincisi, 'url' 'http: // localhost: 8080' –