web.config不包含成员资格部分

时间:2021-07-04 20:21:34

I'm following this walktrough: http://msdn.microsoft.com/en-us/library/879kf95c.aspx to add user login and register pages using out-of-the-box asp.net login and registration controls. For example, for the user registration I'm using CreateUserWizard.

我正在关注这个漫游:http://msdn.microsoft.com/en-us/library/879kf95c.aspx,使用开箱即用的asp.net登录和注册控件添加用户登录和注册页面。例如,对于用户注册,我正在使用CreateUserWizard。

Now I want to customize the registration process, I want to remove the security questions, and add a "Location" field to be asked.

现在我想自定义注册过程,我想删除安全问题,并添加一个“位置”字段来询问。

All articles related to this mention the section "membership" and "profile" in web.config, my problem is they are not there in my web.config. Should I add them manually? Or should they be present (autogenerated).

与此相关的所有文章都提到了web.config中的“membership”和“配置文件”部分,我的问题是它们不在我的web.config中。我应该手动添加它们吗?或者它们应该存在(自动生成)。

2 个解决方案

#1


You have to register your MembershipProvider manually in your web.config:

您必须在web.config中手动注册MembershipProvider:

   <membership>
 <providers>
   <clear/>
    <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" passwordStrengthRegularExpression="" applicationName="/"/>
  </providers>
  </membership>

The connectionString attribute is used to set the name of the connection string registred t in the web.config that is the for your memeberhsip provider

connectionString属性用于设置web.config中注册的连接字符串的名称,该名称是memeberhsip提供程序的名称

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

#2


Go ahead and manually enter the information. When Visual Studio generates a web.config file for you "automagically", it is based on the current project settings and any potential dependencies it may have detected. It doesn't contain every single web.config option and it is safe to add new fields as needed.

继续并手动输入信息。当Visual Studio“自动”为您生成web.config文件时,它基于当前项目设置以及它可能检测到的任何潜在依赖项。它不包含每个web.config选项,并且可以根据需要添加新字段。

#1


You have to register your MembershipProvider manually in your web.config:

您必须在web.config中手动注册MembershipProvider:

   <membership>
 <providers>
   <clear/>
    <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" passwordStrengthRegularExpression="" applicationName="/"/>
  </providers>
  </membership>

The connectionString attribute is used to set the name of the connection string registred t in the web.config that is the for your memeberhsip provider

connectionString属性用于设置web.config中注册的连接字符串的名称,该名称是memeberhsip提供程序的名称

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

#2


Go ahead and manually enter the information. When Visual Studio generates a web.config file for you "automagically", it is based on the current project settings and any potential dependencies it may have detected. It doesn't contain every single web.config option and it is safe to add new fields as needed.

继续并手动输入信息。当Visual Studio“自动”为您生成web.config文件时,它基于当前项目设置以及它可能检测到的任何潜在依赖项。它不包含每个web.config选项,并且可以根据需要添加新字段。