Alex Rivera | Logout

Which Membership Provider implements users stored in web.config?

Asked 2012-09-14T13:47:31.110
11

Having a code-blind moment.

ASP.NET 4.0.

Web.config:

<?xml version="1.0"?>
<configuration>
  <system.web>
    <authentication mode="Forms">
      <forms name="DataViewer" loginUrl="login.aspx">
        <credentials passwordFormat="Clear">
          <user name="devuser" password="test" />
        </credentials>
      </forms>
    </authentication>
    <authorization>
      <deny users="?" />
    </authorization>
  </system.web>

and a login control:

  <asp:Login ID="login" runat="server" />

If I enter a username and password, and click Login, it hangs.

If I break, I can see in the call stack that login.AuthenticateUsingMembershipProvider() is in the middle of calling SqlMembershipProvider.ValidateUser(). There is no database defined or involved in this project at all, and I haven't specified that SqlMembershipProvider should be used.

So my question is, what membership provider should I use to get ASP.NET to use the usernames and passwords in the <credentials> element of web.config?

Edit
Report

1 Answer

3

You are going to need to write your own provider for this. It should be relatively straightforward to take the sample ReadOnlyXmlMembershipProvider in the MSDN documentation and change it to read users and credentials from web.config, instead of an external XML file.

answered 2012-09-14T13:59:56.737

Your Answer