C# 信号机:can';不要连接到任何ip地址

C# 信号机:can';不要连接到任何ip地址,c#,localhost,signalr,signalr-hub,signalr.client,C#,Localhost,Signalr,Signalr Hub,Signalr.client,我正在尝试使用IP地址的信号器,但我无法连接任何IP地址。首先,我尝试了这个服务器URI。”“但是我犯了一些错误。客户端应用程序表示无法连接服务器。这可能是什么原因 public partial class WinFormsServer : Form { private IDisposable SignalR { get; set; } const string ServerURI = "http://localhost:8080/signalr"; private v

我正在尝试使用IP地址的信号器,但我无法连接任何IP地址。首先,我尝试了这个服务器URI。”“但是我犯了一些错误。客户端应用程序表示无法连接服务器。这可能是什么原因

public partial class WinFormsServer : Form
{
    private IDisposable SignalR { get; set; }
    const string ServerURI = "http://localhost:8080/signalr";

    private void ButtonStart_Click(object sender, EventArgs e)
    {
        WriteToConsole("Starting server...");
        ButtonStart.Enabled = false;
        Task.Run(() => StartServer());
    }

    private void StartServer()
    {
        try
        {
            SignalR = WebApp.Start(ServerURI);
        }
        catch (TargetInvocationException)
        {
            WriteToConsole("Server failed to start. A server is already running on " + ServerURI);
            //Re-enable button to let user try to start server again
            this.Invoke((Action)(() => ButtonStart.Enabled = true));
            return;
        }
        this.Invoke((Action)(() => ButtonStop.Enabled = true));
        WriteToConsole("Server started at " + ServerURI);
    }

    class Startup
    {
        public void Configuration(IAppBuilder app)
        {
            app.UseCors(CorsOptions.AllowAll);
            app.MapSignalR();
        }
    }
}
我用Rick van den Bosch的solve代码更改了我的startup类。但我仍然无法连接任何ip地址

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

那么,是否有正在运行的侦听端口8080?netstat-ano | find“:8080”我在cmd上尝试了这个命令,以了解这一点,并将其清除。如果在端口8080上运行的侦听端口8080,则localhost不能运行,但运行了带有localhost的URI。如果我尝试任何IP地址的URI,它不会运行。请查看设置CORS。例如,看看这篇博文:我看了你的答案。我刚改变了我的创业计划,但在客户端我找不到任何可以改变的东西。