C#-ASP.NET Core 2的Visual Studio Code调试器不能与其他端口一起使用

我的意图是使用与默认端口5000不同的端口启动VSCode调试器,为此,我在“ args”数组(命令行args)和ASPNETCORE_URLS env变量中都指定了url.我将以下launch.json配置用于Visual Studio Code调试器:

{
   // Use IntelliSense to find out which attributes exist for C# debugging
   // Use hover for the description of the existing attributes
   // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
   "version": "0.2.0",
   "configurations": [
        {
            "name": ".NET Core Launch (web)",
            "type": "coreclr",
            "request": "launch",
            "preLaunchTask": "build",
            // If you have changed target frameworks, make sure to update the program path.
            "program": "${workspaceFolder}/MotelsBack.API/bin/Debug/netcoreapp2.0/MotelsBack.API.dll",
            "args": ["urls=http://localhost:6000"],
            "cwd": "${workspaceFolder}/MotelsBack.API",
            "stopAtEntry": false,
            "internalConsoleOptions": "openOnSessionStart",
            "launchBrowser": {
                "enabled": true,
                "args": "${auto-detect-url}",
                "windows": {
                    "command": "cmd.exe",
                    "args": "/C start ${auto-detect-url}"
                },
                "osx": {
                    "command": "open"
                },
                "linux": {
                    "command": "xdg-open"
                }
            },
            "env": {
                "ASPNETCORE_ENVIRONMENT": "Development",
                //"ASPNETCORE_URLS": "http://localhost:6000" --Commented, however this don't work also
            },
            "sourceFileMap": {
                "/Views": "${workspaceFolder}/Views"
            }
        },
        {
            "name": ".NET Core Attach",
            "type": "coreclr",
            "request": "attach",
            "processId": "${command:pickProcess}"
        }
    ]
}

调试器在显示以下内容的指定端口上启动:

debugger output image

调试器输出显示可以通过我在前两个选项中指定的URL来访问该应用程序,但是,当我从任何资源管理器访问该URL时,该应用程序均无法访问,只是无法工作,但是如果我删除了端口定义从launch.json使用它可以使用的5000默认端口.

Visual Studio Code调试器不接受其他端口吗?

解决方法:

端口6000是浏览器认为不安全的端口,因此safari和chrome无法连接到它们(safari上的WebKitErrorDomain:103和chrome上的ERR_UNSAFE_PORT).

对ASPNETCORE_URLS环境变量使用不同的非“不安全”端口,它应该可以工作.

目前在ASP.NET Core 2.0中无法通过–urls进行传递,但由于this issue,它将在2.1中传递(有关变通方法,请参阅问题).

上一篇:javascript-Firefox 47中的“暂停例外”在哪里?


下一篇:在OS X上使用Aptana Studio和Xdebug或Zend调试器进行php调试