**Microsoft.Data.SqlClient.SqlException **(0x80131904): 已成功與服務器建立連接,但隨后在登錄程序中發生錯誤。(提供商:SSL 提供商,錯誤:0 - 證書鏈是由不受信任的機構頒發的。) System.ComponentModel.Win32Exception (0x80090325):證書鏈是由不受信任的機構頒發的。在 Microsoft.Data.SqlClient.SqlInternalConnection.OnError(SqlException 例外,布爾 breakConnection,Action`1 wrapCloseInAction)
using WebApplication2.Data;
using WebApplication2.Model.Domain;
namespace WebApplication2.Repositories
{
public class RegionRepository : IRegionRepository
{
private readonly WalksDbContext walksDbContext;
public RegionRepository(WalksDbContext walksDbContext)
{
this.walksDbContext = walksDbContext;
}
public IEnumerable<Region> GetAll()
{
return walksDbContext.Regions.ToList();
}
}
}
uj5u.com熱心網友回復:
我使用了本地資料庫,因此 SSL 提供錯誤已解決。我的本地資料庫名稱是 (localdb)\MSSQLLocalDB 并且也像這樣更改 appsetting.json
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"NzWalks": "server=
(localdb)\\MSSQLLocalDB;database=NzWalksDb;trusted_connection=true"
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/534611.html
