launchsettings.json文件 .NET5

第一、Net5 launchsettings.json文件文件内容:

{
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:62828",
      "sslPort": 44336
    }
  },
  "$schema": "http://json.schemastore.org/launchsettings.json",
  "profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "launchUrl": "swagger",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "netSSL": {
      "commandName": "Project",
      "launchBrowser": true,
      "launchUrl": "swagger",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      },
      "dotnetRunMessages": "true",
      "applicationUrl": "https://localhost:5001;http://localhost:5000"
    }
  }
}

1.默认支持swagger了

 

 原因

       1.本次出现的原因是Api里面的方法重名了(只是方法的参数不一样)

       2.可能是controller中的auction上面少了(hettpget,httpdelete)属性,其它原因也可能引起。

 

 

2.IIS的启动方式支持 http://localhost:62828/swagger/index.html;https://localhost:44336/swagger/index.html这两种方式访问。

3.kestrel的启动方式支持 http://localhost:5000/swagger/index.html;https://localhost:5001/swagger/index.html这两种方式访问。

 

第二、中间件app.UseHttpsRedirection();

检查当前项目启动后,监听的是否是多个端口,其中如果有协议是Https,我们在访问Http时,默认会转发到Https中。

对以上配置文件来说如果访问http://localhost:5000/WeatherForecast,将会跳转到https://localhost:5001/WeatherForecast这个地址

对swagger的访问比较特殊,它在管道中的位置决定了对它的访问不会进行https协议的切换

 

posted @ 2022-04-14 15:49  海爬sir  阅读(297)  评论(0)    收藏  举报