Where does the MVC3 default template store user-ac

2019-04-29 03:03发布

问题:

Can you tell me where the asp.net mvc3 default template stores the login information when I register a new account? It is running local in debug mode.

Without having installed SQLExpress, the register function did not work at all. Since I have installed it, I can use the register/login function, but I can't find the table in SQLExpress where this kind of data is stored. There are master, model, msdb and tempdb in SQLExpress which are system databases.

Can you help me? Thanks!

回答1:

Take a look at the web.config.

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

So the plugged in membership provider is SqlMembershipProvider, using a connection string called ApplicationServices:

<connectionStrings>
    <add name="ApplicationServices"
         connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true"
         providerName="System.Data.SqlClient" />
  </connectionStrings>

So if you look in App_Data in your project (file system), you'll see a file called aspnetdb.mdf, which is where your users are being stored.

Here's some more info on SQL Server Express.