Search code examples
asp.net.netsql-serversqlmembershipprovidersql-server-2014-express

Partial connection to SQL Server 2014 Express


Firstly, this is not a repeat of the same old:

provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified.

Here's the scenario. I'm using ASP.NET membership with a SQLMembershipProvider. This used to work fine, however since a clean install on my development machine and upgrading to SQL Server 2014 Express, I'm now experiencing a strange issue.

When I run the website I get the login form. If I enter an incorrect username and password I get the normal message "invalid username/password". If I enter the correct username / password I get the error 26 as above. I can successfully connect to the database using the same connection string in SQL Server Management Studio, just not from within my ASP.NET Web App.

Connection String:

<connectionStrings> 
   <add name="WEBConnectionString"
        connectionString="Server=SERSQL01\SQLEXPRESS;Initial Catalog=WEBAPP;User ID=MyLogin;Password=MyPassword"         
        providerName="System.Data.SqlClient"
   />
</connectionStrings>

Things I have checked:

  • Instance name is correct.
  • Firewall is disabled.
  • Remote connections are enabled.
  • TCP/IP enabled, port 1433.
  • SQL Browser Enabled.
  • Mixed mode authentication is enabled.
  • Telnet connects successfully.
  • SSSM connects successfully.

Environment:

  • Development Machine: Windows 8.1 with Visual Studio 2013
  • Server: SQL Server 2014 Express on Windows Server 2012 R2

Solution

  • Finally found the problem.

    I was using a custom sql membership provider. But I hadn't extended the role provider:

    <roleManager enabled="true" defaultProvider="SqlProvider" >
            <providers>
                <clear/>
                <add name="SqlProvider" type="System.Web.Security.SqlRoleProvider"
                  connectionStringName="WEBConnectionString" applicationName="/" />
            </providers>
        </roleManager>