c# - 在 ASP.Core MVC 中使用用户名和密码设置连接字符串

标签 c# asp.net-core asp.net-core-mvc

我正在开发我的第一个 ASP.NET Core MVC 应用程序。在具有需要 sql 身份验证的 sql server 后端的 ASP.NET Core MVC 应用程序中指定连接字符串的正确方法是什么?

ArgumentException: Keyword not supported: 'userid'.\

下面是我的 appsettings.json 文件。当我运行该应用程序时,它会抛出一个错误。

{
  "ApplicationInsights": {
    "InstrumentationKey": ""
  },
  "ConnectionStrings": {
      "DefaultConnection": "Server=myserver;Database=mydatabase;userid=id;password=mypwd"
  },
    "Logging": {
      "IncludeScopes": false,
      "LogLevel": {
        "Default": "Debug",
        "System": "Information",
        "Microsoft": "Information"
      }
    }
  }

最佳答案

user<space>id

Server=myServerAddress;Database=myDataBase;User Id=myUsername; Password=myPassword;

https://www.connectionstrings.com/sql-server/

关于c# - 在 ASP.Core MVC 中使用用户名和密码设置连接字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41624783/

相关文章:

c# - 统计一个字符串在一个字符串中出现的次数

c# - 如何知道所有线程池的线程是否已经完成了它的任务?

asp.net-core - 带有消息的自定义错误代码页

c# - Thread.CurrentPrincipal Identity.Name 在 asp.net mvc 6 (vNext) 中为空

c# - NoWarn 在 DNX 中不工作

c# - 以编程方式确定路径是否受限

c# - Asp.net 核心 - 未找到 dotnet 测试

c# - VirtualPathProvider 等同于 ASP.NET 5/MVC6?

git - 如何使用 Git (Bitbucket) 在 Azure 上提供静态站点?

c# - 尝试将图像保存到 wwwroot 时出现 DirectoryNotFoundException