c# - 如果不以管理员身份运行,SignalR、WPF 服务器不会启动

标签 c# wpf signalr

我们正在使用 signalR 而不是原始的 WCF 更新现有的 Windows 桌面软件。 在开始学习 SignalR 时,我们遇到了服务器问题,该服务器以 uri http://localhost:8080 启动良好,但如果我使用 http://*:8080http://MyIPServer:8080 直到我在管理员下运行该程序后它才起作用。

在没有管理员权限的情况下正常运行时,我在webApp.start中出现错误(发生了异常,仅此而已!)。

我在 Windows 防火墙中添加了一条过滤规则来接受所有 8080 端口入站,但没有取得更多成功

代码很简单(来自微软示例):

   const string ServerURI = "http://localhost:8080";
   private void StartServer()
        {
            try
            {
                SignalR = WebApp.Start(ServerURI);
            }
            catch (TargetInvocationException ex)
            {
                WriteToConsole("A server error: " + ex.Message );
                this.Dispatcher.Invoke(() => ButtonStart.IsEnabled = true);
                return;
            }
            this.Dispatcher.Invoke(() => ButtonStop.IsEnabled = true);
            WriteToConsole("Server started at " + ServerURI);
        }

有什么想法吗?

感谢您的帮助。

最佳答案

查看 URL ACL。您可以在命令行上提供启动服务器的权限,如下所示:

netsh http add urlacl http://+:8080/ user=Everyone

您可以使用每个人(必须本地化!)或特定用户。

关于c# - 如果不以管理员身份运行,SignalR、WPF 服务器不会启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34895743/

相关文章:

java - 为什么不能创建没有花括号的 1 语句函数?

c# - 为什么在这种情况下会保存我的设置?

c# - 添加 .resx 文件时 WPF .net Core 3.0 编译错误

asp.net-mvc - 未找到 SignalR 回显/协商?

c# - 无法找到给定输入 : Microsoft. Owin.Host.HttpListener 的服务器工厂

c# - 公开 ReadOnlyCollection 的 ReadOnlyCollection 同时仍然能够在类中修改它的最佳方法

c# - C# 中的图像处理

c# - 如何消除错误 "XamlParseException: Set connectionId threw an exception"?

c# - 使用 signalR 和 C# 每秒向客户端发送消息

c# - 如何传递带有派生类的 Action<in T> 作为 Action 参数?