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

raj*_*raj 6 .net c# 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"
      }
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

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

然后我从另一个远程系统中的 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"
      }
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

Pet*_*ter 8

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

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
Run Code Online (Sandbox Code Playgroud)

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

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

netsh interface ipv4 show excludedportrange protocol=tcp
Run Code Online (Sandbox Code Playgroud)

它看起来像这样:

在此处输入图片说明

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


Ale*_*Dev 5

此问题类似于/sf/answers/4759362191/,可能与 Hyper-v 保留大量端口范围有关。

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

net stop winnat
net start winnat
Run Code Online (Sandbox Code Playgroud)


小智 0

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

我通过在正常模式下运行 VS 和 Chrome 解决了这个问题。