System.Data.SqlClient.SqlException: 'Login failed for user ''.' RRS feed

  • Question

  • User608142609 posted

    Hi Team

    I am getting this exception on my MVC application, on AuthConfig.cs under AppStart folder. Here is my logic for doing this;

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Web;
    using Microsoft.Web.WebPages.OAuth;
    using WebMatrix.WebData;

    namespace eNtsaPortalWebsiteProject
    public class AuthConfig
    public static void RegisterAuth()
    WebSecurity.InitializeDatabaseConnection("MyString", "Users", "UserName", "FullName", autoCreateTables: true);

    // ConnectionString

    <add name="Mystring" providerName="System.Data.SqlClient" connectionString="Data Source=Gcobanim-L\SQLEXPRESS;Database=eNtsaRegistrationDB" />

    I have also try as i still am now, grant permission using sql query to my database and i m not getting any luck either.

    Wednesday, January 22, 2020 10:36 AM

All replies

  • Thursday, January 23, 2020 12:39 AM
  • User753101303 posted


    In particuliar you don't have any credential information inside your connection string. The suggested approach is to add Integrated Security=SSPI. It will then use your own account on your dev machine, the machine account or the account under which your app runs on the web server.

    If you really want to use a SQL account you have to define the User ID and the password (likely the default and as you have no user id it tries to log with no user name causing this message).

    Friday, January 24, 2020 10:34 AM