Question

I hope that the answer to this is as straight forward as I think it is. I just wanted to be sure. So, I have an ASP.NET MVC4 app that uses Forms authentication. I have a database hosted by Arvixe that contains the aspnet_ membership tables. This is the database I have specified in my connection string in my web.config. So, when I hit the Login.cshtml page of my app, and I put my credentials in, is it authenticating against the data in the database I specified in the web.config?

What brings this question on is I set up a user in my database by way of MyWSAT (a third party Web Site Administration Tool that allows managing of user accounts, roles, etc.). I've confirmed that the user is now added in the aspnet_Membership and aspnet_User tables (as well as any other tables). But, when I try to log in using these credentials from my app, it fails on Membership.ValidateUser in my AccountController. It comes back saying Invalid Username/Password. Any ideas on what I might be doing wrong?

Here's my membership provider:

<membership defaultProvider="SqlMembershipProvider" userIsOnlineTimeWindow="15">
  <providers>
    <add
      name="SqlMembershipProvider"
      type="System.Web.Security.SqlMembershipProvider"
      connectionStringName="DefaultConnection"
      applicationName="/"
      enablePasswordRetrieval="true"
      enablePasswordReset="true"
      maxInvalidPasswordAttempts="5"
      requiresQuestionAndAnswer="true"
      requiresUniqueEmail="true"
      passwordFormat="Encrypted" />
  </providers>
</membership>
Was it helpful?

Solution 2

The problem was that my application name needed to be "MyCMS" instead of just blank. When I set up the user account from the MyWSAT tool, I initially set the admin account up under the WSAT tool within the MyWSAT project (the ASP.NET Configuration website), and the application name associated with this was MyCMS.

OTHER TIPS

Do you see "connectionStringName" below? This names the connection string it uses. So look at your web.config and find the connection string called "DefaultConnection" and make sure it points to the correct database or change the connectionStringName to point to the correct connection string.

<membership defaultProvider="SqlMembershipProvider" userIsOnlineTimeWindow="15">
  <providers>
    <add
      name="SqlMembershipProvider"
      type="System.Web.Security.SqlMembershipProvider"
      connectionStringName="DefaultConnection"
      applicationName="/"
      enablePasswordRetrieval="true"
      enablePasswordReset="true"
      maxInvalidPasswordAttempts="5"
      requiresQuestionAndAnswer="true"
      requiresUniqueEmail="true"
      passwordFormat="Encrypted" />
  </providers>
</membership>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top