Asp.net核心 - 无法连接网络服务器'IIS Express'

时间:2016-12-08 12:34:40

标签: c# .net iis asp.net-core

我将启动设置更改为支持远程ip托管

{
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://192.168.1.69:55446/",
      "sslPort": 0
    }
  },
  "profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "myapplication": {
      "commandName": "Project",
      "launchBrowser": true,
      "launchUrl": "http://localhost:5000",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    }
  }
}

它在我的系统中运行良好。

然后我从另一个远程系统的tfs下载我的项目并更改了ipaddress以支持远程ip托管并在管理员模式下运行应用程序..但仍显示“无法连接网络服务器'IIS Express'”

 {
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://192.168.1.79:55446/",
      "sslPort": 0
    }
  },
  "profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "eBMSForumApplication": {
      "commandName": "Project",
      "launchBrowser": true,
      "launchUrl": "http://localhost:5000",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    }
  }
}

7 个答案:

答案 0 :(得分:7)

如果您在输出控制台中看到类似的内容:

IIS Express starting...
iis express Failed to register URL "http://localhost:61367/" for site application "/". 
Error description: The process cannot access the file because it is being used by 
another process

错误是由于您使用的端口造成的。

打开控制台并使用以下命令检查使用的端口范围:

netsh interface ipv4 show excludedportrange protocol=tcp

它看起来像这样:

enter image description here

更改您要使用的端口号,该端口号超出这些范围。

答案 1 :(得分:1)

就我而言,我在调试中从项目属性中取消选中“启用 SSL”并运行该项目。它弹出了一个 iis,显示该端口正在被 chrome 使用。所以我关闭了所有 chrome 实例并再次切换到“启用 SSL”,它解决了我的问题。

答案 2 :(得分:0)

我最近也遇到了这个问题(以及其他一些问题:如果chrome已打开,VS 2019不会在chrome中打开Web应用程序项目),并发现我正在以管理员模式运行VS。

我通过在正常模式下运行VS和Chrome来解决此问题。

答案 3 :(得分:0)

在我的情况下,我已经在调试模式下修改了项目url,但在该URL无法运行后,我不得不重新启动Visual Studio才能使其正常工作。

答案 4 :(得分:0)

同样的事情发生了,但我不知道原因,我重新启动了 IIs 和 VS,但没有用。然后我重新启动了电脑,一切都修复了。

答案 5 :(得分:0)

我的项目版本 2.2 enter image description here 我的电脑版本 5.0 (cmd: dotnet --list-sdks) enter image description here

我在我的电脑上安装了 2.2 版。我现在可以运行应用程序了。

答案 6 :(得分:0)

此问题与 https://stackoverflow.com/a/67990888/733760 类似,可能与 Hyper-v 保留一堆端口范围有关。

如果这是问题所在,那么同样的答案适用(并且对我有用)。 以管理员身份运行:

net stop winnat
net start winnat