偷偷摘套内射激情视频,久久精品99国产国产精,中文字幕无线乱码人妻,中文在线中文a,性爽19p

淺析ASP.NET的Membership

開發(fā) 后端
本文介紹ASP.NET的Membership,以及介紹把程序copy到遠(yuǎn)程服務(wù)器上然后運(yùn)行。由于某種原因,雖然我們能夠連接到Membership數(shù)據(jù)庫(kù),但是當(dāng)?shù)顷懙臅r(shí)候就會(huì)出現(xiàn)錯(cuò)誤了。

在本地開發(fā)一個(gè)ASP.NET2.0的應(yīng)用程序時(shí)使用了Membership、Roles或Profile特性。你創(chuàng)建了ASP.NET一些新用戶,一切都沒(méi)有問(wèn)題。

然后把這個(gè)程序copy到遠(yuǎn)程服務(wù)器(remote server)上(或者只是移動(dòng)到你本地服務(wù)器上的其他目錄)然后運(yùn)行。由于某種原因,雖然我們能夠連接到Membership數(shù)據(jù)庫(kù),但是當(dāng)?shù)顷懙臅r(shí)候就會(huì)出現(xiàn)錯(cuò)誤了,它并不拋出連接錯(cuò)誤(connection error),而是提示你像類似的錯(cuò)誤:“嘗試登陸失敗,請(qǐng)重試”(Login attempt unsuccessful, please try again)

原因:
這種經(jīng)常出現(xiàn)的錯(cuò)誤的原因是因?yàn)镸embership(或者是roles、profile) provider已經(jīng)被加入到了程序的web.config里了。但是applicationName屬性(attribute)并沒(méi)有被指定(假設(shè)下面的代碼的粗體部分布存在地話)

  1. <membership> 
  2. <providers> 
  3. <clear/> 
  4. <add name="AspNetSqlMembershipProvider" 
  5. type="System.Web.Security.SqlMembershipProvider, System.Web, 
    Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
     
  6. connectionStringName="LocalSqlServer" 
  7. enablePasswordRetrieval="false" 
  8. enablePasswordReset="true" 
  9. requiresQuestionAndAnswer="true" 
  10. requiresUniqueEmail="false" 
  11. passwordFormat="Hashed" 
  12. maxInvalidPasswordAttempts="5" 
  13. minRequiredPasswordLength="7" 
  14. minRequiredNonalphanumericCharacters="1" 
  15. passwordAttemptWindow="10" 
  16. passwordStrengthRegularExpression="" 
  17. applicationName="/" 
  18. /> 
  19. </providers> 
  20. </membership> 

如果它被copy到其他的地方或服務(wù)器上并且更換了虛擬路徑(比如說(shuō)“/app1” 或更通常被設(shè)置的“/”)后,當(dāng)Membership APIs被使用時(shí)他們就“看”不到數(shù)據(jù)庫(kù)里已有的用戶了——因?yàn)樗麄儗?huì)使用一個(gè)不同的applicationName去數(shù)據(jù)庫(kù)里尋找用戶,相應(yīng)地過(guò)濾 application_Users表中的用戶。這就是為什么會(huì)出現(xiàn)上面錯(cuò)誤的原因。

如何解決這個(gè)問(wèn)題:
最簡(jiǎn)單的辦法是打開ASPNETDB數(shù)據(jù)庫(kù)中的aspnet_Users和aspnet_Application表,去“回想”(figure out,因?yàn)槟菚r(shí)候我們的虛擬目錄叫什么名字我們恐怕已經(jīng)忘了)創(chuàng)建用戶和其他數(shù)據(jù)的時(shí)候的程序名稱(去aspnet_Application表中查找)

然后打開你的web.config文件,添加一個(gè)applicationName屬性到provider聲明的地方并且給他賦值,例如,下面的代碼我們把它設(shè)置為在aspnet_Application表存在的/website8:

  1. <membership> 
  2. <providers> 
  3. <clear/> 
  4. <add name="AspNetSqlMembershipProvider" 
  5. type="System.Web.Security.SqlMembershipProvider, System.Web, 
    Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
     
  6. connectionStringName="LocalSqlServer" 
  7. enablePasswordRetrieval="false" 
  8. enablePasswordReset="true" 
  9. requiresQuestionAndAnswer="true" 
  10. requiresUniqueEmail="false" 
  11. passwordFormat="Hashed" 
  12. maxInvalidPasswordAttempts="5" 
  13. minRequiredPasswordLength="7" 
  14. minRequiredNonalphanumericCharacters="1" 
  15. passwordAttemptWindow="10" 
  16. passwordStrengthRegularExpression="" 
  17. applicationName="/website8" 
  18. /> 
  19. </providers> 
  20. </membership> 

以上介紹ASP.NET的Membership

【編輯推薦】

  1. ASP.NET的TypeConverter
  2. 淺析ASP.NET的TypeResolver
  3. ASP.NET中定義JavaScriptConverter
  4. 在ASP.NET中替換Sys.Services的方法
  5. 使用ASP.NET AJAX的Profile Service
責(zé)任編輯:佚名 來(lái)源: IT專家網(wǎng)
相關(guān)推薦

2009-08-05 13:58:26

ASP.NET Mem

2009-12-07 09:23:05

ASP.NET MVC

2009-07-27 10:18:12

TypeResolveASP.NET

2009-07-31 12:43:59

ASP.NET MVC

2009-08-05 15:50:13

ASP.NET優(yōu)點(diǎn)

2009-07-24 13:41:15

ASP.NET AJA

2009-08-05 18:36:12

ASP.NET Che

2009-08-10 13:32:15

ASP.NET TimASP.NET組件設(shè)計(jì)

2009-07-22 18:03:00

ASP.NET ASP

2009-08-27 17:20:30

ASP.NET登陸控件membership配

2009-07-28 10:59:13

ASP.NET IIS

2009-07-23 14:31:20

ASP.NET MVC

2009-07-28 16:40:11

ASP.NET異步頁(yè)面

2009-07-20 16:23:01

ASP.NET授權(quán)模塊

2009-08-05 14:46:17

ASP.NET url

2009-07-28 15:53:43

ASP.NET Web

2009-08-04 17:00:09

ASP.NET禁用Vi

2009-07-28 13:35:18

2009-07-29 14:12:45

ASP.NET tra

2009-08-05 16:50:09

ASP.NET For
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)