我試圖讓使用Visual Studio的Mac OS X「HttpContext.IsWebSocketRequest」屬性和「HttpContext.AcceptWebSocketRequest」方法在哪裏?
哪裏HttpContext.IsWebSocketRequest
屬性和 HttpContext.AcceptWebSocketRequest
方法我的Mac上一個簡單的「Hello World」式的WebSocket服務器上運行?該文件似乎說,他們是在System.Web DLL中的HttpContext,但我已經引用(以及System.Net)和Visual Studio找不到它們。
有什麼我失蹤或忘記?
這是我給我的問題的代碼。
using System;
using System.Web;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Net.WebSockets;
using System.Collections.Generic;
public void ProcessRequest(HttpContext context)
{
if (context.IsWebSocketRequest)
context.AcceptWebSocketRequest(HandleWebSocket);
else
context.Response.StatusCode = 400;
}
我下面的示例是:https://github.com/paulbatum/WebSocket-Samples/blob/master/AspNetWebSocketEcho/EchoHandler.ashx.cs
請確保您使用.NET 4.5 – Trey
'mcs --version'告訴我我正在使用「Mono C#編譯器版本4.8.0.0」,它只能在Windows上受支持嗎? – Kris