C
C#4d ago
maddog1994

✅ IIS >> .NET 9 API >> SQL Connection String set up.

Hello All, I am new to .NET (LAMP dev background) I am trying to learn .NET as best I can but i have hit a roadblock in trying to deploy to an IIS server. I know where my issue is but I cannot figure out how to configure it correctly. I have built a simple REST API and have tested the code, it works in Visual Studio. I have SQL Developer installed on my machine and my code persists to it just fine in VS. Now, all i am trying to do is "deploy" it to IIS (locally, all of my assets are local, no remote connections). Now I know it has to do with the way my application is communicating through the IIS server to the SQL instance. I have many different ways based on documentation I have found, but nothing is clearly straight forward. From what I can tell there are two possible ways to connect IIS communication from the app to the SQL server. 1. Windows Authentication Creds 2. Some sort of trusted pass through (because its all local). If I could get an example of what i am supposed to create for the connection string and where to put it (appsettings.json or connection strings in IIS config ... or both???) That would be helpful.
51 Replies
Jimmacle
Jimmacle4d ago
IIS has nothing to do with how your app talks to your database also, i wouldn't start using IIS if you don't have a specific reason to all your app needs is a valid connection string for your db, which will depend on how your db is set up and where it's hosted there are a million ways to get the connection string into your app, whether that's environment variables, appsettings, some other file, a cloud secret storage service, etc
Unknown User
Unknown User4d ago
Message Not Public
Sign In & Join Server To View
MODiX
MODiX4d ago
If you have no further questions, please use /close to mark the forum thread as answered
Unknown User
Unknown User4d ago
Message Not Public
Sign In & Join Server To View
maddog1994
maddog1994OP4d ago
I know this is going to come off the wrong way, but I just have to point things out as they happen. Jimmale ... "IIS has nothing to do with how your app talks to your database" actually, I am pretty sure it does, see picture1 from IIS Manager. "i wouldn't start using IIS if you don't have a specific reason to all your app needs is a valid connection string for your db, which will depend on how your db is set up and where it's hosted" The reason for me to use IIS was not part of my initial questioning, but since you mentioned it, yes I do have a valid reason to use IIS. However, none of those reasons pertain to the initial inquiry that I posted. "there are a million ways to get the connection string into your app, whether that's environment variables, appsettings, some other file, a cloud secret storage service, etc" This response kinda gets in the ballpark of what I originally was asking, however still comes short on actual sustenance. As I mentioned in my post, I am trying to "deploy" my application to my local IIS server, WHICH in turn, my app would communicate with my database instance. IE... I am trying to mimic deploying an application to a server, similar to how it would be done on a remote server (ie The need to use IIS and learn it). As far as the "million ways" to do it, I doubt that, but there are a few that I know of...: AppSettings.json, web.config,and also....I am assuming the IIS configurations and perhaps more. So, in short, I suppose thanks for attempting to assist me, albeit completely off the mark. I guess I'll have to find what I am looking for elsewhere.
No description
Jimmacle
Jimmacle4d ago
cool beans, good luck i'll be over here with my ASP.NET Core app hosted in IIS that has no IIS specific database code and works fine
maddog1994
maddog1994OP4d ago
Yes, I know my connection string needs to be updated, my question is how??? Firewall is good 👍 I think this might be close to what I am looking for, but again "how" is the question. I have seem lots of stuff regarding these topics in MS docs and other forums, but nothing that really "explains" it
Jimmacle
Jimmacle4d ago
it seems the issue is you don't know enough to know what you need to know, in which case telling the people who do know that they don't know what they're talking about is counterproductive
maddog1994
maddog1994OP4d ago
Wow, you've got some issues bud
Jimmacle
Jimmacle4d ago
the reason i asked about IIS is because it's only one option for deploying an ASP.NET Core app (and not a good one), and the reason i can't be specific about the connection string is because you haven't mentioned how you want to authenticate to it
maddog1994
maddog1994OP4d ago
This is the "help" forum, right?
Jimmacle
Jimmacle4d ago
yes, so when people offer help telling them they're wrong isn't a great look
maddog1994
maddog1994OP4d ago
From what you are saying is , If I dont know, well then I shouldn't even bother asking becasue I am not as good as you ?
Unknown User
Unknown User4d ago
Message Not Public
Sign In & Join Server To View
maddog1994
maddog1994OP4d ago
What isn't a good look is your arrogant response.
Jimmacle
Jimmacle4d ago
pot meet kettle good luck with your problem
maddog1994
maddog1994OP4d ago
@Jimmacle dude, just go away..... geeze
Jimmacle
Jimmacle4d ago
i'm just confused why you're sabotaging your own post :PepeLaugh:
Unknown User
Unknown User3d ago
Message Not Public
Sign In & Join Server To View
Jimmacle
Jimmacle3d ago
have we even established that we're using windows authentication?
Unknown User
Unknown User3d ago
Message Not Public
Sign In & Join Server To View
maddog1994
maddog1994OP3d ago
@tobeco now this sounds more like on the mark of what I am looking for,,,,,, thanks @tobeco the project is not serious at all. its just a test env/sandbox......
Unknown User
Unknown User3d ago
Message Not Public
Sign In & Join Server To View
maddog1994
maddog1994OP3d ago
as I said in my initial post, I am a LAMP dev, I havn't done anything remotwly close to .NET in over 15 years
Jimmacle
Jimmacle3d ago
there's no real reason to use IIS unless you actually plan to deploy to an IIS server, which nobody here will recommend if you have a choice especially for local dev
maddog1994
maddog1994OP3d ago
user/pass is how I think I initially set it up, but I still get 500
Unknown User
Unknown User3d ago
Message Not Public
Sign In & Join Server To View
Jimmacle
Jimmacle3d ago
500 is not a database error, that is an error returned by your application so you'll need to check your application's logs
maddog1994
maddog1994OP3d ago
geeze he is still talking 😕
Unknown User
Unknown User3d ago
Message Not Public
Sign In & Join Server To View
maddog1994
maddog1994OP3d ago
the 500 error is because my API call cannot connect to the DB
Jimmacle
Jimmacle3d ago
and what does that error say?
maddog1994
maddog1994OP3d ago
I verified in the error logs
Jimmacle
Jimmacle3d ago
full stack trace if possible
Unknown User
Unknown User3d ago
Message Not Public
Sign In & Join Server To View
maddog1994
maddog1994OP3d ago
sec .... correction ..... SQL log error, the 500 is being returned to the browser .... 06/02/2025 10:22:00,Logon,Unknown,Login failed for user 'TCH-AZ\ITAPW11$'. Reason: Could not find a login matching the name provided. [CLIENT: <local machine>] 06/02/2025 10:22:00,Logon,Unknown,Error: 18456<c/> Severity: 14<c/> State: 5.
Jimmacle
Jimmacle3d ago
so what does that tell us
maddog1994
maddog1994OP3d ago
my connection string is not configured correctly, which is what I knew
Jimmacle
Jimmacle3d ago
i mean, it could be correct depending on how you want to authenticate and you have misconfigured your sql server do you want to use windows authentication or a sql user/password?
maddog1994
maddog1994OP3d ago
either/or honestly, our production is already set up here for ISS so, all I will really have to do is deploy the code. i am jsut trying to get a simple test/dev enviroment going so I can mimic AND learn as best I can. Everything I am trying to do is all local. nothing of what I am trying to do is gong to be production settings. This is just a sandbox text
Jimmacle
Jimmacle3d ago
the second way is generally less painful
maddog1994
maddog1994OP3d ago
I initally set it up for windows auth
Jimmacle
Jimmacle3d ago
add a user to your db with sql authentication, then use that username and password in the connection string
maddog1994
maddog1994OP3d ago
that didnt work, so I tried to use user/pass
Jimmacle
Jimmacle3d ago
it looks like your current connection string is set up for windows authentication, and it's complaining that the user your app is running as doesn't have a database login remove trusted connection and/or integrated security from the connection string, that's just a confusing way to say use windows authentication or just add a login for that user
maddog1994
maddog1994OP3d ago
ok, ill try that
Unknown User
Unknown User3d ago
Message Not Public
Sign In & Join Server To View
engineertdog
engineertdog3d ago
Outside of containers, what would the recommendation be for server-side deployment without IIS? Granted, I'm probably looking to use JS frontends and not MAUI/Blazor, but that's beside the point
Jimmacle
Jimmacle3d ago
regular old service kestrel itself is a production ready web server reverse proxy it behind something else if that tickles your fancy, but it's not required
engineertdog
engineertdog3d ago
Yeah, that's fair. I still deal with a lot of .NET Framework which is beyond annoying, but for the .NET8+ it's straight forward.
Unknown User
Unknown User3d ago
Message Not Public
Sign In & Join Server To View

Did you find this page helpful?