SignalR 2.0跨域,控制台作为服务器端无法正常工作

时间:2015-04-17 05:24:31

标签: cross-domain signalr

这是我的服务器端代码

class Program
{
    static void Main(string[] args)
    {

        string url = "http://localhost:8080";

        using (WebApp.Start<Startup>(url))
        {
            Console.WriteLine("Server running on {0}", url);
        }
    }
}



public class Startup
{
    public void Configuration(IAppBuilder app)
    {
        app.Map("/signalr", map =>
        {
            map.UseCors(CorsOptions.AllowAll);                
            var hubConfiguration = new HubConfiguration
            {

            };

            map.RunSignalR(hubConfiguration);
        });
    }
}

当我运行控制台应用并浏览&#39; http://localhost:8080/signalr/hubs&#39;在服务器上,它显示了一些jQuery代码但是当我尝试浏览&#39; http://[server-ip]/signalr/hubs&#39;时,它在服务器和客户端上显示错误400

这是否意味着我的服务器端应用程序还不允许跨域?

1 个答案:

答案 0 :(得分:0)

这里有解决方案:

变化

string url = "http://localhost:8080";

string url = "http://+:8080";
相关问题