Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Application cannot open SQL connection when on IIS

I have a connection string that looks like this:

Server=.;Database=mydbname;Trusted_Connection=True;

This works fine when I run/debug my application using Visual Studio (IIS Express) but after deployment over IIS-8 it throws me an exception while opening connection that:

Login failed for user 'IIS APPPOOL\mysite'.

I am confused why this is happening why IIS is adding its user in the middle when the database doesn't require one, and why this is not happening with IIS Express?


1 Answers

You're using Trusted_Connection=True and thus the user ApplicationPoolIdentity or IIS APPPOOL\mysite is supplied to SQL server.

Option 1. Give permissions to IIS APPPOOL\mysite in SQL server.

Option 2. Use User Id=User_Id;Password=****** instead of Trusted_Connection=True

like image 103
maxbeaudoin Avatar answered Oct 30 '25 12:10

maxbeaudoin