SwaggerEndpoint 异常:请求路径不得以斜杠结尾
SwaggerEndpoint exception: Request path must not end in a slash
我正在按照 MS 文档 link 在 ASP.NET 核心 2.0 web API 中使用 Swagger UI。
执行所有步骤后,当我在 VS 2017 中本地 运行 我的项目时,我收到以下异常。
System.ArgumentException: "Request path must not end in a slash"
当我按照文档中的说明添加以下行时发生异常:
c.RoutePrefix = string.Empty;
当我不设置 RoutePrefix 并转到“https://localhost:44392//swagger/v1/swagger.json”时,我得到一个 JSON 格式的输出。我期待 UI。
任何解决方案或提示将不胜感激。
编辑
当我尝试通过“https://localhost:44392//swagger”
访问它时出现错误消息
{"data":{},"status":"Failure","message":"Method not found: 'Void Microsoft.Net.Http.Headers.EntityTagHeaderValue..ctor(System.String)'."}
您必须访问 https://localhost:44392/swagger 以获得 UI,就像文档中显示的那样。您发布的 link 会将您引导至 JSON 文档,该文档旨在
我刚刚弄明白了。
我需要做的事情很少:
- 删除"c..RoutePrefix = string.Empty;"
- 通过 https://localhost 访问 Swagger UI:<'port'>/swagger/
- 安装 Microsoft.AspNetCore.StaticFiles v2.0.0.0 nuget 包以解决 'method not found' 错误。
谢谢大家。
我正在按照 MS 文档 link 在 ASP.NET 核心 2.0 web API 中使用 Swagger UI。
执行所有步骤后,当我在 VS 2017 中本地 运行 我的项目时,我收到以下异常。 System.ArgumentException: "Request path must not end in a slash"
当我按照文档中的说明添加以下行时发生异常:
c.RoutePrefix = string.Empty;
当我不设置 RoutePrefix 并转到“https://localhost:44392//swagger/v1/swagger.json”时,我得到一个 JSON 格式的输出。我期待 UI。 任何解决方案或提示将不胜感激。
编辑 当我尝试通过“https://localhost:44392//swagger”
访问它时出现错误消息{"data":{},"status":"Failure","message":"Method not found: 'Void Microsoft.Net.Http.Headers.EntityTagHeaderValue..ctor(System.String)'."}
您必须访问 https://localhost:44392/swagger 以获得 UI,就像文档中显示的那样。您发布的 link 会将您引导至 JSON 文档,该文档旨在
我刚刚弄明白了。 我需要做的事情很少:
- 删除"c..RoutePrefix = string.Empty;"
- 通过 https://localhost 访问 Swagger UI:<'port'>/swagger/
- 安装 Microsoft.AspNetCore.StaticFiles v2.0.0.0 nuget 包以解决 'method not found' 错误。
谢谢大家。