我已经在azure上发布了我的websocket,并且我已经在我的网络应用程序中启用了Web套接字功能,但是当我连接到我的网络套接字时,我一直收到IsWebSocketRequest
错误,请注意本地使用localhost它正常工作< / p>
if (context.IsWebSocketRequest)
context.AcceptWebSocketRequest(new TestWebSocketHandler());
以下是我的网络应用配置
答案 0 :(得分:0)
我不清楚你的错误是什么原因。
您可以参考此sample。
我在获取方法中添加了IsWebSocketRequest
,并在本地和天蓝色的地方运行,它运行正常。
public HttpResponseMessage Get(string username)
{
HttpContext currentContext = HttpContext.Current;
if (currentContext.IsWebSocketRequest)
{
HttpContext.Current.AcceptWebSocketRequest(new ChatWebSocketHandler(username));
}
return Request.CreateResponse(HttpStatusCode.SwitchingProtocols);
}