简体   繁体   English

launchSettings.json 文件打开错误的 URL

[英]launchSettings.json file opens wrong URL

When I try I couldn't run this project in my computer today but my teammates can run at their own computer.当我尝试时,我今天无法在我的计算机上运行这个项目,但我的队友可以在他们自己的计算机上运行。 By the way I can run other projects.顺便说一句,我可以运行其他项目。 My launchSettings file like this:我的launchSettings文件是这样的:

{
 "$schema": "http://json.schemastore.org/launchsettings.json",
 "iisSettings": {
   "windowsAuthentication": false,
   "anonymousAuthentication": true,
   "iisExpress": {
     "applicationUrl": "http://localhost:4321",
     "sslPort": 0
   }
 },
 "profiles": {
   "IIS Express": {
     "commandName": "IISExpress",
     "launchBrowser": true,
     //"launchUrl": "User",
     "launchUrl": "swagger",
     "environmentVariables": {
       "ASPNETCORE_ENVIRONMENT": "Development"
     }
   },
   "Dashboard.WebAPI": {
     "commandName": "Project",
     "launchBrowser": true,
     "launchUrl": "User",
     "applicationUrl": "http://localhost:5000",
     "environmentVariables": {
       "ASPNETCORE_ENVIRONMENT": "Development"
     }
   }
 }
}

But when I run this project my url is opening as "https://localhost:4321/swagger/index.html".但是当我运行这个项目时,我的网址打开为“https://localhost:4321/swagger/index.html”。 I guess this problem is because this url is run as "https" but my applicationUrl is "http".我猜这个问题是因为这个 url 作为“https”运行,但我的 applicationUrl 是“http”。

What could be the cause of this problem?这个问题的原因可能是什么?

Edit: My browser:编辑:我的浏览器:

错误

Either disable Https redirection in your Startup.cs/Program.cs depending whether you use .net5 or .net6 or put your sslPort value in launchSettings.json to a 4322 port (or some other of your choosing, just not any that are in use) and it'll work.要么在 Startup.cs/Program.cs 中禁用 Https 重定向,具体取决于您使用的是 .net5 还是 .net6,或者将您在 launchSettings.json 中的 sslPort 值设置为 4322 端口(或您选择的其他端口,而不是任何正在使用的端口) ),它会工作。

Edit:编辑:

{
 "$schema": "http://json.schemastore.org/launchsettings.json",
 "iisSettings": {
   "windowsAuthentication": false,
   "anonymousAuthentication": true,
   "iisExpress": {
     "applicationUrl": "http://localhost:4321","https://localhost:4322",
     "sslPort": 4322
   }
 },
 "profiles": {
   "IIS Express": {
     "commandName": "IISExpress",
     "launchBrowser": true,
     //"launchUrl": "User",
     "launchUrl": "swagger",
     "environmentVariables": {
       "ASPNETCORE_ENVIRONMENT": "Development"
     }
   },
   "Dashboard.WebAPI": {
     "commandName": "Project",
     "launchBrowser": true,
     "launchUrl": "User",
     "applicationUrl": "http://localhost:5000","https://localhost:5001"
     "environmentVariables": {
       "ASPNETCORE_ENVIRONMENT": "Development"
     }
   }
 }
}

On the Visual Studio toolbar their is a dropdown that allows you to select which profile to run.在 Visual Studio 工具栏上,它们是一个下拉菜单,允许您选择要运行的配置文件。 I suspect you are running the IIS Express profile when you want to run the Dashboard.WebAPI profile.当您想运行 Dashboard.WebAPI 配置文件时,我怀疑您正在运行 IIS Express 配置文件。 If you see "IIS Express" on your toolbar with a green arrow to the left of it then select the dropdown and choose Dashboard.WebAPI (see mocked up image below)如果您在工具栏上看到“IIS Express”,其左侧有一个绿色箭头,则选择下拉菜单并选择 Dashboard.WebAPI(请参见下面的模拟图像)

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从 launchsettings.json 获取当前应用程序 url - How to get current application url from launchsettings.json Visual Studio for Mac 忽略launchSettings.json - Visual Studio for Mac Ignoring launchSettings.json 微服务未在 LaunchSettings.JSON 设置的端口上启动 - Microservice not Launching on Port Set by LaunchSettings.JSON Launchsettings.json 不是使用 dotnet new 创建的 - Launchsettings.json not created using dotnet new 运行单元测试时是否可以加载来自 launchSettings.json 文件的配置文件? - Can a profile from the launchSettings.json file be loaded when running unit tests? launchSettings.json 和 appSettings.json 是如何工作的? - how do launchSettings.json and appSettings.json work? 如何在 linux 上的 launchsettings.json 中引用环境变量 - How to reference environment variables in launchsettings.json on linux 是否可以在 launchsettings.json 中将 executablePath 指定为相对路径? - Is it possible to specify executablePath as a relative path in launchsettings.json? 在launchSettings.json中引用环境变量的值 - Referring to environment variable's value inside launchSettings.json 根据构建配置选择launchSettings.json配置文件 - Choose launchSettings.json profile based on build configuration
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM