-1

I have an ASP.NET application and it's working fine with Visual Studio IDE. I installed IIS and added a virtual directory. Now I get an error "login fail for user domain\computer name".

My connection string which is still working fine in ide run:

<add name="cricConnectionString" 
     connectionString="Data Source=AMDKLAPTOP031\RAMDEV;Initial Catalog=cric;Integrated Security=True"
     providerName="System.Data.SqlClient" />

but I get an error when its run using IIS:

System.Data.SqlClient.SqlException: Login failed for user domain\computername$

When I tried to add new login in SQL Server, it can't find domain\computername shown in the error. domain\computername is not a valid name because it contains invalid characters. Error code is 15006

Tauqeer
  • 129
  • 1
  • 1
  • 8
  • How does your SQL connection string look like? – Nenad Mar 28 '20 at 20:53
  • How did you try to add the user? What domain and username, what exact command did you use? What does your question have to do with C#? – mason Mar 28 '20 at 21:23
  • When you run from VS, the webapp runs under your account, so your credentials are used for the connection. When you install on IIS, it runs as a separate service account - that you need to explicitly grant access to sqlserver – Hans Kesting Apr 07 '20 at 07:13

1 Answers1

0

You need to add a login to SQL Server for IIS APPPOOL\ASP.NET v4.0 and grant permissions to the database.

In SSMS, under the server, expand Security, then right click Logins and select "New Login...".

Read more from here Login failed for user 'IIS APPPOOL\ASP.NET v4.0'

Hiba F
  • 9
  • 2