asp.net更改密码格式问题

时间:2011-07-13 10:23:05

标签: asp.net passwords asp.net-membership

我在web.config中更改了我的密码格式,用于哈希加密并添加了一个机器密钥,但之后我收到了这个错误:

Format of the initialization string does not conform to specification starting at index 0

我尝试改回哈希但我仍然遇到这个错误。

这是会员代码:

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

和连接字符串:

    <connectionStrings>
    <remove name="LocalSqlServer"/>
    <add name="LocalSqlServer" connectionString="Data Source=AHMED-PC\SQLEXPRESS;Initial Catalog=test;Persist Security Info=True;User ID=sa;Password=123456" providerName="System.Data.SqlClient"/>
</connectionStrings>

注意:在我更改密码格式之前,连接字符串工作正常。

使用asp.net 4.0

问题是什么,谢谢。

1 个答案:

答案 0 :(得分:1)

通过附加ASPNETDB.MDF文件并从连接字符串中删除初始目录来解决它:

      <connectionStrings>
   <remove name="localsqlserver"/>
        <add name="localsqlserver" connectionString="Data Source=AHMED-PC\SQLEXPRESS;AttachDBFilename=|DataDirectory|aspnetdb.mdf;Persist Security Info=True;User ID=sa;Password=123456" providerName="System.Data.SqlClient"/> 
</connectionStrings>