【问题标题】:signalR some cookie not sent to hub -cross domainsignalR 一些 cookie 未发送到集线器 - 跨域
【发布时间】:2017-11-11 00:04:23
【问题描述】:

我添加了 cookie 密钥,但新的 cookie 密钥没有发送到服务器。 当我控制台 document.cookie 时,我看到了新值。但在请求中看不到,

客户端代码(角度):

$cookies.InternalToken = credentials.token;
_connectionHub
   .start();

集线器代码(.net c#):

var connection = new HubConnection(url);
connection.CookieContainer = new System.Net.CookieContainer();
connection.CookieContainer.Add(new System.Net.Cookie() { Name = "InternalToken", Value = "" });

【问题讨论】:

    标签: c# web signalr cross-domain


    【解决方案1】:

    尝试为 cookie 设置域

    connection.CookieContainer.Add(new System.Net.Cookie("InternalToken", "<value>") { Domain = new Uri(<"Host" of destination URL>);
    

    编辑
    我假设您已经检查了集线器是否收到了 cookie

    【讨论】:

      猜你喜欢
      • 2020-12-20
      • 1970-01-01
      • 2016-08-03
      • 2012-08-29
      • 2019-11-05
      • 2021-03-05
      • 2013-10-14
      • 2013-01-05
      • 1970-01-01
      相关资源
      最近更新 更多