c# - 运行应用程序时在 VSCode 中的 ASP.NET Core 应用程序中启动特定 URL
问题描述
(如果重要的话,可以在 Mac 上运行。)
在 Visual Studio 中,您可以在运行或调试 ASP.NET Core 项目时使用此方法启动特定 URL。使用了 launchUrl 属性。这是一个示例 launchSettings.json 文件:
{
"profiles": {
"MyProjectName": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "customstartupurlgoeshere/?id=theanswertotheuniverse",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:5001;http://localhost:5000"
}
}
}
VS Code 中的类比是什么?我读到 VS Code 忽略了 launchSettings.json 文件。
解决方案
VSCode.vscode/launch.json
在启动程序时进行配置。
使用了 launchUrl 属性.... VS Code 中的类比是什么?
您可以更改args
参数以接受 的参数--urls
。例如,如果你想让红隼听6001
/ 6000
:
“配置”:[ { "name": ".NET Core Launch (web)", “类型”:“coreclr”, “请求”:“启动”, "preLaunchTask": "构建", "程序": "${workspaceFolder}/bin/Debug/netcoreapp3.0/App.dll", "args": ["--urls","https://localhost:6001;http://localhost:6000"], "cwd": "${workspaceFolder}", “stopAtEntry”:假, “serverReadyAction”:{ "action": "openExternally", “模式”:“^\\s*现在正在监听:\\s+(https?://\\S+)” }, “环境”:{ "ASPNETCORE_ENVIRONMENT": "发展" }, “源文件映射”:{ "/Views": "${workspaceFolder}/Views" } },
推荐阅读
- flutter - 如何让一个小部件从下面来并将自己堆叠在当前屏幕的顶部?
- javascript - 如何使用没有键对的对象访问属性的值?
- javascript - 尝试通过 function.php 将一些自定义文本添加到 Wordpress 帖子标题中
- python - 使用函数计算并显示从1到用户在python中输入的数字的所有数字的平均值
- arrays - 如何计算嵌套哈希的所有值的总和?
- html - HTML 表格格式:rowspan = 0 的问题
- javascript - 标签 javascript 一直隐藏所有标签
- lstm - 在 BERT 嵌入之上训练 LSTM 期间出现“IndexError: index out of range in self”错误
- attributeerror - 嗖嗖过滤引发 AttributeError:'Term' 对象没有属性 'Term'
- javascript - 动态 CSS Javascript 函数失败(可能是由于连字符)