I have an ASP.NET application which has been working by creating a context to connect to a SQL Server 2016 database. So far it's been working great, but I've been tasked with adding javascript into the code to retrieve data from the database and display it to the user. I've heard connecting directly to the database through Javascript has security risks due to users being able to see the username and password, so I wanted to know if there's a safe alternative to direct connection that would have the Javascript code call server-side code and retrieve the data (stored in the database as JSON). I know AJAX is how to retrieve the code and have learned a decent amount about it, but I don't know how to get the connection string that AJAX needs to function. I've heard Node.js could work, but we already have a server stood up so I'm pretty confused. Any advice would be much appreciated!
Side note: I know there's already a good explanation of why a direct connection is bad here, but while the top answer says "A better way to connect to a sql server would be to use some server side language like PHP, Java, .NET, among others." they didn't explain how to connect through the server side with .NET