Reputation: 11
I'm working on my first real MVC project and my task is to implement a custom membership provider. I have implemented one before in asp.net 3.5 Web Forms so I'm trying to reuse some of that code if possible. Our data comes from a remote web service so I won't be using any of the standard membership database. Based on some research and experience in Web Forms I created my class:
public class wwdllMembershipProvider : MembershipProvider
I put the following in web.config:
<authentication mode="Forms">
<forms loginUrl="~/Account/Login" timeout="2880" />
</authentication>
<membership defaultProvider="wwdllMembershipProvider" userIsOnlineTimeWindow="15">
<providers>
<add name="wwdllMembershipProvider" type="wwdllMembershipProvider" enablePasswordRetrieval="false" enablePasswordReset="false" writeExceptionsToEventLog="false" enablePasswordChange="true" />
</providers>
</membership>
From there I was just going to try to see if any of the stubbed out code in my membership provider was being hit. But as soon as I click on the login link in the app I get the following error:
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) Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: 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)
Source Error:
Line 55: using (var context = new UsersContext())
Line 56: {
Line 57: if (!context.Database.Exists())
Line 58: {
Line 59: // Create the SimpleMembership database without Entity Framework migration schema
Source File: c:\Users\mburt\Documents\Visual Studio 2012\Projects\eSales\4300\Siriusware.eSales\Filters\InitializeSimpleMembershipAttribute.cs Line: 57
Which is puzzling to me because I didn't think the Simple Membership Provider code would execute because of the web.config setting disabling it.
Can someone point out to me what I'm doing wrong? Thanks!
Upvotes: 1
Views: 485
Reputation: 830
The default account controller is decorated with that very attribute. Check if that is still present.
(Default MVC4 project code below.)
namespace MvcApplication2.Controllers
{
[Authorize]
[InitializeSimpleMembership]
public class AccountController : Controller
{
[...]
}
}
Upvotes: 2