0

I am deploying my project from Visual Studio to IIS following a tutorial and using SQL Server Management Studio.Whenever i try to open the project by typing "http://localhost:84/" ( as it was the configured port ), I get the error message:

Server Error in '/' Application.

Cannot open database "MyIMDB" requested by the login. The login failed. Login failed for user 'PC19\MyIMDBUser'.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Cannot open database "MyIMDB" requested by the login. The login failed. Login failed for user 'PC19\MyIMDBUser'.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

I had already done what is proposed in

Login failed for user 'IIS APPPOOL\ASP.NET v4.0'

the user I created is the PC19\MyIMDBUser

There is any other way by which I can keep track of what is happening step by step in the database?Like, see when it try to login, what the user it uses, password and such? Something like the breakpoint on Visual Studio maybe? Anything that I can gather more info about what is happening and why the project is doing that?

バカです
  • 175
  • 2
  • 4
  • 18
  • Your application is authenticating to the database using windows credential, probably the IIS runs under that local user account. You could either change the authentication of the application to require windows credentials and passtrouh them to the database or use database logins and edit the connection string accordl. BTW, this is most probably already answered. – Cleptus Oct 10 '17 at 11:51
  • Possible duplicate of [Login failed for user 'IIS APPPOOL\ASP.NET v4.0'](https://stackoverflow.com/questions/7698286/login-failed-for-user-iis-apppool-asp-net-v4-0) – Cleptus Oct 10 '17 at 11:58
  • There *is* an account called `CORP\PC19$`. It's `PC19`s *computer* account. Computers in a domain have accounts just as much as users do. – Damien_The_Unbeliever Oct 10 '17 at 12:12

1 Answers1

0

Go to IIS --> Application pools and change identity user

enter image description here

Dmitrij Kultasev
  • 5,447
  • 5
  • 44
  • 88
  • There are several alternatives, set a specific account, changing authentication and passthrough then to database, using database logins in the connectionstring... – Cleptus Oct 10 '17 at 12:01
  • I did that and now it's trying to login on the right user but still can't login. It shows "Cannot open database "MyIMDB" requested by the login. The login failed. Login failed for user 'PC19\MyIMDBUser'." – バカです Oct 10 '17 at 12:24
  • When most probably your user doesn't have access rights to the db. Can you connect to db using your windows credentials? – Dmitrij Kultasev Oct 10 '17 at 12:29
  • @IngridSL did you enable TCP/IP on SQL Server? – Dmitrij Kultasev Oct 10 '17 at 12:31
  • Check your SQL Server logins and the database users. – Cleptus Oct 10 '17 at 12:34
  • @bradbury9, found out! It was a mixture of various errors. First, the connectionstring was mnimally wrong and as the mistake was so small, that I didn't noticed. Second, the Visual Studio didn't include in the project a whole folder. So, there was a lot of files that were non-existent to the final version when I pressed the "publish" button – バカです Oct 10 '17 at 13:02