1
初始化成員資格提供我試圖通過代碼來初始化SQL成員資格提供程序,一切都僅在第一要求做工精細! 當下面的代碼再次執行(清爽例如頁面後)我收到以下錯誤:通過代碼
屬性「的connectionStringName」缺少或爲空。
頁面加載代碼:
MembershipSection membershipSection = (MembershipSection)ConfigurationManager.GetSection("system.web/membership");
string sqlProviderName = "AspNetSqlMembershipProvider";
NameValueCollection providerConfig;
providerConfig = membershipSection.Providers[sqlProviderName].Parameters; // returning empty list in the second request
var _SqlProvider = new SqlMembershipProvider();
_SqlProvider.Initialize(sqlProviderName, providerConfig);
Web.config文件:
<membership defaultProvider="AspNetSqlMembershipProvider">
<providers>
<clear />
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ConnectionString" enablePasswordRetrieval="true" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="true" passwordFormat="Encrypted" maxInvalidPasswordAttempts="5" passwordAttemptWindow="10" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" applicationName="/" />
</providers>
</membership>
什麼建議嗎?
微軟的答案! https://connect.microsoft.com/VisualStudio/feedback/details/813107/membership-provider-parameters-disappear-after-first-request –