【问题标题】:How to change port on built ASP .NET API如何更改内置 ASP .NET API 的端口
【发布时间】:2022-01-07 10:51:20
【问题描述】:

我正在尝试使用 ASP .NET 制作一个简单的 REST API,当我在我的计算机上运行 API 时,端口就是我指定的任何端口。但是,当它在我的服务器上发布并运行时,它始终是端口 5000。更好的是,swagger UI 也不会显示。如果您需要,我可以提供更多信息!谢谢!

硬件:RPI 3B+ 操作系统:Raspbian(最新)

LaunchSettings.json:

{
  "$schema": "https://json.schemastore.org/launchsettings.json",
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
        "applicationUrl": "http://localhost:3061",
        "sslPort": 44303
      }
    },
    "profiles": {
      "SS_API": {
        "commandName": "Project",
        "dotnetRunMessages": true,
        "launchBrowser": true,
        "launchUrl": "swagger",
        "applicationUrl": "https://localhost:7009;http://localhost:5009;https://0.0.0.0:5001",
        "environmentVariables": {
          "ASPNETCORE_ENVIRONMENT": "Development"
        }
     }
   }
}

【问题讨论】:

  • 你能告诉我们更多关于服务器环境的信息吗?操作系统、Web 服务器堆栈(IIS 等)?
  • Raspbian,RPI 3B+,我不确定 Web 服务器堆栈。如何检查?

标签: c# asp.net api asp.net-web-api


【解决方案1】:

检查launchSettings.json。 也许您的应用程序在此环境中启动时使用了不同的启动配置文件。如果您使用的是 IIS - 还要检查 web.config 文件

【讨论】:

  • 嘿!感谢您的回复!我没有看到 web.config 文件,那在哪里?另外,我很抱歉成为这样的新手,但我不确定如何检查启动配置文件。我在帖子中留下了我的 launchSettings.json。你能告诉我吗?
  • web.config 通常位于 ASP.NET Core 项目的根目录中。如果它不存在,那么,很可能,您没有使用 IIS。关于 launchSettings.json - 它位于 ASP.NET Core 项目根目录下的 Properties 文件夹中。
  • 我想我当时没有使用 IIS!我的 launchSettings.json 在属性文件夹中。
猜你喜欢
  • 2023-03-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-04-04
  • 2018-05-12
  • 2011-11-03
  • 2021-06-14
  • 2014-09-14
相关资源
最近更新 更多