Login failed for user 'MachineName\ASPNET'


If you are trying to login to a web application and getting login Failed for 'MachineName/ASPNET' error then here is a simple solution for the problem. To solve it you just need to execute code in query analyzer to add the user and grant permissions.

Login failed for user 'MachineName\ASPNET'



If you are trying to login to a web application and getting login Failed for 'MachineName/ASPNET' error then here is a simple solution of the problem.

To solve it you just need to execute below code in SQL query analyzer to add the user and grant permissions.

I hope it will be useful for all who is facing this issue.



Solution of error:



What you need to do is add the MACHINENAME\ASPNET user as a Login in your database, and give that user rights to the database objects it needs.
When an ASP.NET application tries to access your SQL Server database, it does so by using that account.

To do so please execute the below code in query analyzer to add the user and grant permissions.

Note:You need to Change the 'MachineName\ASPNET' to your computer name and dbname to your database name in the below code.




Begin
DECLARE @username sysname

SELECT @username = 'MachineName\ASPNET'

USE master
EXEC sp_grantlogin @username

USE
EXEC sp_grantdbaccess @username

EXEC sp_addrolemember N'db_owner', @username

End


Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: