<bdo id='mFtI0'></bdo><ul id='mFtI0'></ul>

      <i id='mFtI0'><tr id='mFtI0'><dt id='mFtI0'><q id='mFtI0'><span id='mFtI0'><b id='mFtI0'><form id='mFtI0'><ins id='mFtI0'></ins><ul id='mFtI0'></ul><sub id='mFtI0'></sub></form><legend id='mFtI0'></legend><bdo id='mFtI0'><pre id='mFtI0'><center id='mFtI0'></center></pre></bdo></b><th id='mFtI0'></th></span></q></dt></tr></i><div id='mFtI0'><tfoot id='mFtI0'></tfoot><dl id='mFtI0'><fieldset id='mFtI0'></fieldset></dl></div>
    1. <small id='mFtI0'></small><noframes id='mFtI0'>

      <legend id='mFtI0'><style id='mFtI0'><dir id='mFtI0'><q id='mFtI0'></q></dir></style></legend>

      <tfoot id='mFtI0'></tfoot>

      如何使用 SignalR 使用跨域连接(CORS - 访问控制允许来源)

      时间:2023-09-14
      <tfoot id='y156G'></tfoot>

      <small id='y156G'></small><noframes id='y156G'>

        <i id='y156G'><tr id='y156G'><dt id='y156G'><q id='y156G'><span id='y156G'><b id='y156G'><form id='y156G'><ins id='y156G'></ins><ul id='y156G'></ul><sub id='y156G'></sub></form><legend id='y156G'></legend><bdo id='y156G'><pre id='y156G'><center id='y156G'></center></pre></bdo></b><th id='y156G'></th></span></q></dt></tr></i><div id='y156G'><tfoot id='y156G'></tfoot><dl id='y156G'><fieldset id='y156G'></fieldset></dl></div>
          <tbody id='y156G'></tbody>
          • <bdo id='y156G'></bdo><ul id='y156G'></ul>

            1. <legend id='y156G'><style id='y156G'><dir id='y156G'><q id='y156G'></q></dir></style></legend>

              • 本文介绍了如何使用 SignalR 使用跨域连接(CORS - 访问控制允许来源)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                使用持久连接和 ASP.NET JavaScript 客户端,我尝试连接到与提供页面的子域不同的子域.

                Using persistent connections and an ASP.NET JavaScript client, I am trying to connect to a sub-domain not the same as the one the page was served from.

                ASP.Net 页面想要连接到位于 sub2.mydomain.com 的 SignalR.在同一子域中连接时,相同的代码可以正常工作.

                ASP.Net Page from webserver sub1.mydomain.com wants to connect to SignalR at sub2.mydomain.com. The same code works fine when connecting within the same sub-domain.

                我发现另一个帖子启用了跨域连接:

                I found another post where cross-domain connections were enabled with:

                jQuery.support.cors = true;
                

                但这对我不起作用.

                如何使用持久连接和 JavaScript 客户端连接到第二个子域中的 SignalR?

                How can I connect to SignalR in a second sub-domain using persistent connection and a JavaScript client?

                推荐答案

                您需要执行以下操作之一才能使其工作:

                You need to do one of the following to make it work:

                • 设置 $.connection.hub.url = 'http://subdomain.domain.com/signalr';,指向您的子域.
                • 在服务器上启用跨域:

                • Set up $.connection.hub.url = 'http://subdomain.domain.com/signalr';, pointing to your subdomain.
                • Enable cross domain on the server:

                RouteTable.Routes.MapHubs(new HubConfiguration()
                {
                  EnableCrossDomain = true
                });
                

                这篇关于如何使用 SignalR 使用跨域连接(CORS - 访问控制允许来源)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:.NET Web API CORS PreFlight 请求 下一篇:即使允许几乎所有内容,ASP.NET 5/Core/vNext CORS 也无法正常工作

                相关文章

                <small id='N6SK5'></small><noframes id='N6SK5'>

                <tfoot id='N6SK5'></tfoot>

              • <i id='N6SK5'><tr id='N6SK5'><dt id='N6SK5'><q id='N6SK5'><span id='N6SK5'><b id='N6SK5'><form id='N6SK5'><ins id='N6SK5'></ins><ul id='N6SK5'></ul><sub id='N6SK5'></sub></form><legend id='N6SK5'></legend><bdo id='N6SK5'><pre id='N6SK5'><center id='N6SK5'></center></pre></bdo></b><th id='N6SK5'></th></span></q></dt></tr></i><div id='N6SK5'><tfoot id='N6SK5'></tfoot><dl id='N6SK5'><fieldset id='N6SK5'></fieldset></dl></div>
              • <legend id='N6SK5'><style id='N6SK5'><dir id='N6SK5'><q id='N6SK5'></q></dir></style></legend>

                  • <bdo id='N6SK5'></bdo><ul id='N6SK5'></ul>