加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net-mvc-4 – 如何从asp.net mvc 4中的空Web应用程序模板创

发布时间:2020-12-16 07:00:43 所属栏目:asp.Net 来源:网络整理
导读:如何从空的ASP.NET MVC 4模板开始配置简单成员资格提供程序? 我在谷歌,必应和其他许多人上搜索了很多,但我对会员提供商没有得到任何积极的回应. 有人可以告诉我简单会员提供者的基本知识吗? 解决方法 我刚刚完成了整个过程,步骤如下.我假设您将使用Entity
如何从空的ASP.NET MVC 4模板开始配置简单成员资格提供程序?

我在谷歌,必应和其他许多人上搜索了很多,但我对会员提供商没有得到任何积极的回应.

有人可以告诉我简单会员提供者的基本知识吗?

解决方法

我刚刚完成了整个过程,步骤如下.我假设您将使用Entity Framework进行数据访问并已将其设置为:

>参考库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>

>将GlobalSeas.cs中的WebSecurity.InitializeDatabaseConnection(“DefaultConnection”,“UsersTableName”,“UserId”,“UserName”,true)添加到Application_Start()>确保您的数据库文件存在并包含相应的表. UserId属性应为int类型.>通过执行WebSecurity.CreateUserAndAccount(“testUser”,“myStrongPassword”)来测试所有内容.如果它通过,你是明确的.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读