.NET 6 Connect to sql server on IIS (window server)

  Kiến thức lập trình

I have a sql server and IIS service running on Window Server 2019. I wrote some API populating the data in database in the BE code which is located in the IIS site folder.

In the appsettings.json file I set the connection strings as below:
Server=myServerIpAddress;Database=myDataBase;User Id=myUsername;Password=myPassword;

My API still works fine if I open the port 1433 in the firewall but as I read some cautions, it could lead to some serious security issue.

I’ve tried set the connection strings like: Server=localhost;Database=myDataBase;Trusted_Connection=True; without opening the port but my API doesn’t work anymore.

May I have some solutions for this issue?

Thanks for taking a look at my question. Have a nice day!!

LEAVE A COMMENT