1
votes

Hi, I am trying to use the default asp.net membership provider in asp.net mvc 4 but it seems to be failing when connecting to the database. Here are the settings I have made in web.config:

<add name="MembershipConnectionString" connectionString="Data
Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\aspnetdb.mdf;Integrated
Security=True" providerName="System.Data.SqlClient"/>

 <membership>
  <providers>
    <clear/>
    <add  name="AspNetSqlMembershipProvider"
          type="System.Web.Security.SqlMembershipProvider"
          connectionStringName="MembershipConnectionString"
          enablePasswordRetrieval="false"
          enablePasswordReset="true"
          requiresQuestionAndAnswer="false"
          requiresUniqueEmail="false"
          maxInvalidPasswordAttempts="5"         
          minRequiredNonalphanumericCharacters="0"
          passwordAttemptWindow="10"
          applicationName="/"
          passwordFormat="Hashed"
         />
  </providers>
</membership>

I should mention that I upgraded the database generated from asp.net regex to my current SQL Server when I added the connection.

Now when I try to open the ASP.NET Web Site Adminstration Tool and I go to security and tried to create a user or a role I got this error:

The following message may help in diagnosing the problem:

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified) at System.Web.Administration.WebAdminPage.CallWebAdminHelperMethod(Boolean isMembership, String methodName, Object[] parameters, Type[] paramTypes) at ASP.security_users_adduser_aspx.PopulateCheckboxes() in c:\Windows\Microsoft.NET\Framework64\v4.0.30319\ASP.NETWebAdminFiles\Security\Users\addUser.aspx:line 28 at ASP.security_users_adduser_aspx.Page_Load() in c:\Windows\Microsoft.NET\Framework64\v4.0.30319\ASP.NETWebAdminFiles\Security\Users\addUser.aspx:line 22 at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) at System.Web.UI.Control.OnLoad(EventArgs e) at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

What am I doing wrong?

1
Did you make sure the user of the AppPool running the site has a login for the database and the correct permissions to select/insert/update?Elad Lachmi
I am not using IIS just the default IIS Express that comes with visual studio 2012aleczandru
"The server was not found or was not accessible" - the connection details are wrongKieren Johnstone

1 Answers

4
votes

Are you sure datasourse is correct ? because looks like problem is not with membership but it is unable to find server.so you should check with connection string first. try to connect to database without membership first then if done,you can go further.