如何配置從空的ASP.NET MVC 4模板開始的簡單成員資格提供程序?如何從asp.net mvc 4中的空web應用程序模板製作簡單的會員供應商?
我在Google,Bing和其他許多人身上搜索了很多,但是我沒有得到關於會員提供商的任何積極迴應。
有人能告訴我簡單的會員供應商的基本知識嗎?
如何配置從空的ASP.NET MVC 4模板開始的簡單成員資格提供程序?如何從asp.net mvc 4中的空web應用程序模板製作簡單的會員供應商?
我在Google,Bing和其他許多人身上搜索了很多,但是我沒有得到關於會員提供商的任何積極迴應。
有人能告訴我簡單的會員供應商的基本知識嗎?
我剛剛經歷了這個過程,其步驟如下。我假設你將使用實體框架進行數據訪問,並將它已經建立了:
WebMatrix.Data
和WebMatrix.WebData
。你會發現他們 大會在/在添加引用對話框擴展Web.config
:<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=(localdb)\v11.0;Initial Catalog=LicenceAudit.mdf;Integrated Security=SSPI;attachDBFilename=|DataDirectory|\LicenceAudit.mdf" providerName="System.Data.SqlClient" />
</connectionStrings>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="v11.0" />
</parameters>
</defaultConnectionFactory>
</entityFramework>
<system.web>
<membership defaultProvider="simpleMembershipProvider">
<providers>
<add name="SimpleMembershipProvider" type="WebMatrix.WebData.SimpleMembershipProvider, WebMatrix.WebData"/>
</providers>
</membership>
<roleManager enabled="true" defaultProvider="SimpleRoleProvider">
<providers>
<clear/>
<add name="SimpleRoleProvider" type="WebMatrix.WebData.SimpleRoleProvider, WebMatrix.WebData"/>
</providers>
</roleManager>
</system.web>
WebSecurity.InitializeDatabaseConnection("DefaultConnection", "UsersTableName", "UserId", "UserName", true)
到Application_Start()
在Global.asax.cs
int
。WebSecurity.CreateUserAndAccount("testUser", "myStrongPassword")
來測試所有內容。如果它通過,你就清楚了。這裏是一個短一篇文章,一步如何ASP.NET SimpleMembership添加到現有的MVC 4應用程序描述的步驟: