日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
SQLite開發(fā)中的MermbershipProvider

偶然在CodeProject中發(fā)現(xiàn)土耳其人mascix已經(jīng)重寫了一套使用SQLite進(jìn)行用戶管理的Membership Provider,原文地址:http://www.codeproject.com/KB/aspnet/SQLiteProviders.aspx

創(chuàng)新互聯(lián)公司網(wǎng)站建設(shè)服務(wù)商,為中小企業(yè)提供成都做網(wǎng)站、網(wǎng)站設(shè)計(jì)服務(wù),網(wǎng)站設(shè)計(jì),綿陽服務(wù)器托管等一站式綜合服務(wù)型公司,專業(yè)打造企業(yè)形象網(wǎng)站,讓您在眾多競(jìng)爭(zhēng)對(duì)手中脫穎而出創(chuàng)新互聯(lián)公司。

如果對(duì)SQLite本地?cái)?shù)據(jù)庫開發(fā)和數(shù)據(jù)庫進(jìn)行開發(fā)的過程不太了解可以參考我上一篇文章《SQLite開發(fā)準(zhǔn)備》。

我們將mascix的代碼下載到本地打開,目錄中所見的ProviderSql.sql是Membership相關(guān)表的建表SQL文,我們使用SQLite Manager新建TestDatabas.sqlite數(shù)據(jù)庫。當(dāng)然我們也可以使用mascix在他的文章中推薦的SQLite Administrator來進(jìn)行數(shù)據(jù)庫的創(chuàng)建。

SQL文運(yùn)行完,數(shù)據(jù)庫中就會(huì)創(chuàng)建出如下六張數(shù)據(jù)表:

  • Roles
  • UsersInRoles
  • aspnet_applications
  • aspnet_profile
  • personalization
  • users

而mascix所寫的代碼的精華都在App_Code文件夾下的代碼里,為了以后復(fù)用這套代碼,我決定創(chuàng)建一個(gè)單獨(dú)的C#工程命名為SQLiteProviders。

并將App_Code代碼中的名稱空間都修改為SQLiteProviders(這里刪除了mascix.前綴,并不是忽視版權(quán)而是為了遵守代碼規(guī)范)。

新建的工程需要引用:

  • System.Web
  • System.Data.SQLite.DLL
  • System.Web.ApplicationServices
  • System.Security

編譯后創(chuàng)建一個(gè)新的Web工程,修改web.config代碼如下:

 
 
 
  1.   
  2.   
  3.     
  4.          connectionString="Data Source=|DataDirectory|users.sqlite;Version=3;" />
  5.   
  6.   
  7.     
  8.       
  9.     
  10.     
  11.     
  12.     
  13.     
  14.       defaultProvider="SQLiteRoleProvider"
  15.       enabled="true"
  16.       cacheRolesInCookie="true"
  17.       cookieName=".ASPROLES"
  18.       cookieTimeout="30" cookiePath="/"
  19.       cookieRequireSSL="false"
  20.       cookieSlidingExpiration="true"
  21.       cookieProtection="All">
  22.       
  23.         
  24.         
  25.           name="SQLiteRoleProvider"
  26.           type="SQLiteProviders.SQLiteRoleProvider"
  27.           connectionStringName="ConnString"
  28.           applicationName="CoolSpirit"
  29.           writeExceptionsToEventLog="true"/>
  30.       
  31.     
  32.     
  33.                 userIsOnlineTimeWindow="15">
  34.       
  35.         
  36.         
  37.           name="SQLiteMembershipProvider"
  38.           type="SQLiteProviders.SqliteMembershipProvider"
  39.           connectionStringName="ConnString"
  40.           applicationName="CoolSpirit"
  41.           enablePasswordRetrieval="false"
  42.           enablePasswordReset="true"
  43.           requiresQuestionAndAnswer="false"
  44.           requiresUniqueEmail="true"
  45.           passwordFormat="Hashed"
  46.           writeExceptionsToEventLog="true"/>
  47.       
  48.     
  49.     
  50.       
  51.         
  52.         
  53.           name="SQLiteProfileProvider"
  54.           type="SQLiteProviders.SQLiteProfileProvider"
  55.           connectionStringName="ConnString"
  56.           applicationName="CoolSpirit"/>
  57.       
  58.       
  59.     
  60.     
  61.       
  62.         
  63.           
  64.           
  65.                type="SQLiteProviders.SQLitePersonalizationProvider"
  66.                connectionStringName="ConnString"
  67.                applicationName="CoolSpirit"
  68.                description="SQLite Personalization Provider"
  69.                />
  70.         
  71.       
  72.     
  73.   

添加對(duì)SQLiteProviders項(xiàng)目的引用,別忘了以鏈接文件引用SQLite.Interop.DLL(見《SQLite開發(fā)準(zhǔn)備》一文)然后編譯Web應(yīng)用程序。

編譯通過后,在Visual Studio的菜單“項(xiàng)目”-“ASP.NET配置”,即可打開ASP.NET配置站點(diǎn),在安全鏈接的右側(cè),如果能看見“使您能夠設(shè)置和編輯用戶、角色和對(duì)站點(diǎn)的訪問權(quán)限。 現(xiàn)有用戶: 0 ”的字樣即代表配置成功,隨后可以像ASP.NET Membership Provider一樣通過登陸控件等實(shí)現(xiàn)系統(tǒng)登陸、用戶注冊(cè)、用戶和角色管理等功能了。


當(dāng)前名稱:SQLite開發(fā)中的MermbershipProvider
網(wǎng)頁URL:http://www.5511xx.com/article/cddpssh.html