【问题标题】:Whats wrong with my ConnectionString? When I test my API in Postman I get an error [closed]我的 ConnectionString 有什么问题?当我在 Postman 中测试我的 API 时出现错误 [关闭]
【发布时间】:2021-10-26 09:21:54
【问题描述】:

我第一次尝试连接我的数据库 (PostgreSQL - pgaAdmin)。

我在:appsettings.json 中完成了我的 ConnectionString。之后,我做了一个 APIController。

我想在 Postman 中测试我的 API。我在尝试测试时遇到错误:

System.Net.Sockets.SocketException:不知道这样的主机(错误代码:11001)

我想我的连接字符串有问题,但我不知道它在哪里。

【问题讨论】:

  • 根据标签指南,请不要在您的问题标题中添加标签。如果您是新用户,请务必使用tour 并阅读How to Ask 和相关主题,以确保您了解在本网站上发布的惯例。

标签: c# database postgresql connection-string


【解决方案1】:

尝试在连接字符串中使用“Server=localhost”而不是“Host=localhost”

【讨论】:

  • 我用链接(Uwe Keim 的链接)重写了我的 ConnectionString,它是有效的。太感谢了! (新的连接字符串:“User ID=postgres;Password=asd123;Host=localhost;Port=5432;Database=StudyO;Pooling=true;Connection Lifetime=0;”)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-01-26
  • 1970-01-01
  • 1970-01-01
  • 2015-12-21
  • 2011-08-08
  • 1970-01-01
  • 2018-07-13
相关资源
最近更新 更多