Search code examples
asp.net-mvc-4membership-provider

Configuring Membership Provider with credentials setup in web.config


I'm trying to implement Forms Authentication in ASP.NET MVC4 application and I've only one user who is going to get authenticated to do some admin activities.

<authentication mode="Forms">
  <forms timeout="2880" loginUrl="~/Admin/Login" slidingExpiration="true">
    <credentials passwordFormat="Clear">
      <user name="user" password="password"/>
    </credentials>
  </forms>
</authentication>

When I try to use the FormsAuthentication.ValidateUser method I get an obsolete warning and I'm supposed to use now Membership class.

My question is how I can configure membership provider in web.config to use the credentials setup in the web.config? What provider I should specify in the name attribute?


Solution

  • Unfortunately, there is no built-in membership provider for the mechanism of storing the credentials in the web.config as you describe. You could write your own to invoke the FormsAuthentication.Authenticate method or call this from your own custom login control's code-behind.