Mikayil Abdullayev
Mikayil Abdullayev

Reputation: 12367

Authentification works when browsed from Visual Studio but not with IIS

I have a ASP.NET website. It's got a login page where I use built-in Membership class for user authentication. I've got a weird problem. In visual Studio when I point to my Default.aspx file and select View in browser I have no problem, I enter credentials and authenticate. But when I open the same website from the browser directly (localhost/MyWebsite) either authentication fails or I get the following error:

Cannot open database requested by the login. The login failed.Login failed for user ‘NT AUTHORITY\NETWORK SERVICE’."

I use SQL Server express for Membership. I've put the mdf file in the App_Data folder.

Upvotes: 1

Views: 93

Answers (1)

Jupaol
Jupaol

Reputation: 21355

If you are using::

Integrated Security

In your connection string, then it only means that ASP.Net is trying to connect with your database using the current AppPool identity in this case, the AUTHORITY\NETWORK SERVICE

You could change your database authentication mechanism to use a user/password and avoid this problem

Another solution is grant required permissions to the AUTHORITY\NETWORK SERVICE user in your database

Upvotes: 1

Related Questions