Application cannot open SQL connection when on IIS
asp.net-mvc-4, c#, iis, sql-server-2012
Solution
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`
Problem
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?