Полная ошибка:
Код: Выделить всё
WebSockets is unsupported in the current application configuration To
enable this, set the following configuration switch in Web.config:
For more information, see http://go.microsoft.com/fwlink/?LinkId=252465..
at System.Web.Util.SynchronizationContextUtil.ValidateMode(SynchronizationContextMode currentMode,
SynchronizationContextMode requiredMode, String specificErrorMessage)
at System.Web.HttpContext.AcceptWebSocketRequest(Func`2 userFunc, AspNetWebSocketOptions options)
at Microsoft.AspNet.SignalR.Transports.WebSocketTransport.AcceptWebSocketRequest(Func`2 callback)
at Microsoft.AspNet.SignalR.PersistentConnection.ProcessRequestPostGroupRead(HostContext context,
String groupsToken)
at Microsoft.AspNet.SignalR.TaskAsyncHelper.FromMethod[T1,T2,T3,TResult]
(Func`4 func, T1 arg1, T2 arg2, T3 arg3)
Потому что я устанавливаю соединение с SignalR.
Код: Выделить всё
$(function () {
var asset1 = document.getElementById('MainContent_MainContent_Asset1Hidden').value;
var asset2 = document.getElementById('MainContent_MainContent_Asset2Hidden').value;
var socket = $.connection.marketHub;
socket.client.refreshSellOrders = function (msg) {
document.getElementById("MainContent_MainContent_sellOrders").innerHTML = msg;
};
socket.client.refreshBuyOrders = function (msg) {
document.getElementById("MainContent_MainContent_buyOrders").innerHTML = msg;
};
socket.client.refreshCompletedOrders = function (msg) {
document.getElementById("MainContent_MainContent_completedOrders").innerHTML = msg;
};
$.connection.hub.qs = { 'asset1': asset1, 'asset2': asset2 };
$.connection.hub.start();
});
Дополнительный код, который вам может понадобиться:
Код: Выделить всё
public class MarketHub : Hub
{
public static readonly System.Timers.Timer _Timer = new System.Timers.Timer();
static MarketHub()
{
}
public override System.Threading.Tasks.Task OnConnected()
{
string mAsset1 = Context.QueryString["asset1"];
string mAsset2 = Context.QueryString["asset2"];
string body = "{0}/{1}";
string roomName = string.Format(body, mAsset1, mAsset2);
JoinRoom(roomName);
return base.OnConnected();
}
public System.Threading.Tasks.Task JoinRoom(string roomName)
{
System.Threading.Tasks.Task result = Groups.Add(Context.ConnectionId, roomName);
return result;
}
}
Код: Выделить всё
protected void Application_Start(object sender, EventArgs e, IAppBuilder app)
{
app.MapSignalR();
GlobalConfiguration.Configure(config =>
{
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/v2/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
});
}
Код: Выделить всё
Подробнее здесь: https://stackoverflow.com/questions/636 ... figuration
Мобильная версия