SignalR 远程访问并跨域

 

http://stackoverflow.com/questions/16875228/how-do-i-get-a-signalr-hub-connection-to-work-cross-domain

 

SignalR 远程访问并跨域

命令:Install-Package Microsoft.Owin.Cors

using Microsoft.AspNet.SignalR;
using Microsoft.Owin.Cors;
using Owin;
namespace MyWebApplication
{
    public class Startup
    {
        public void Configuration(IAppBuilder app)
        {
            // Branch the pipeline here for requests that start with "/signalr"
            app.Map("/signalr", map =>
            {
                // Setup the CORS middleware to run before SignalR.
                // By default this will allow all origins. You can 
                // configure the set of origins and/or http verbs by
                // providing a cors options with a different policy.
                map.UseCors(CorsOptions.AllowAll);
                var hubConfiguration = new HubConfiguration 
                {
                    // You can enable JSONP by uncommenting line below.
                    // JSONP requests are insecure but some older browsers (and some
                    // versions of IE) require JSONP to work cross domain
                    // EnableJSONP = true
                };
                // Run the SignalR pipeline. We're not using MapSignalR
                // since this branch already runs under the "/signalr"
                // path.
                map.RunSignalR(hubConfiguration);
            });
        }
    }
}

 https://www.asp.net/signalr/overview/guide-to-the-api/hubs-api-guide-javascript-client#nogenconnection

 

 

SignalR 远程访问并跨域

 

相关文章:

  • 2021-09-08
  • 2021-06-08
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-06-25
  • 2022-12-23
  • 2021-11-25
  • 2021-03-30
相关资源
相似解决方案