2015年7月31日 星期五

Your login attempt was not successful. Please try again.

Your login attempt was not successful. Please try again.

http://forums.asp.net/t/959371.aspx?Your+login+attempt+was+not+successful+Please+try+again+

http://weblogs.asp.net/scottgu/443634

正在研究...
form:
http://www.codeproject.com/Articles/27682/Your-Login-Attempt-was-not-Successful-Please-Try

This article will discuss some prevent /cure measures for the error: “Your login attempt was not successful. Please try again.”

Introduction

If you are developing using ASP.NET membership and login controls, you will be seeing the above image. This article will discuss how to prevent and/or cure this.

Background

Generally I have seen that when developers use ASP.NET membership provider and login controls, they come across this error. They will complain:
  • I have a user in the database and am still not able to login.
  • It worked fine on the local machine and when moved to host, it won't let me login.
  • Etc.
So I will be discussing some points which I have assembled from my own experience as well as from others.
Note: I am assuming here that you are using aspnetdb or used aspnet_regsql.exe to create default membership database. I will try to point out explicitly about custom dataschema.

User Specific Details

Check Password

  • Wrong Password: Often people might think they are entering the correct password but they are not. So make sure you are entering the correct password. If you have any doubts about this, create a new test user and write down the password and make sure it is what you are entering when trying to log-in.
  • Trim Password: Secondly, sometimes when you are debugging you can see the password you are entering looks the same in code-behind when you debug the Login1.Password value is correct. But that might not be the case. Suppose you are copy/pasting the password from a file or somewhere, accidentally a space is added while copying it. So Trim the password before feeding it to Membership.Validate method.

Check UserName

  • Same rules as the password above.
Check the following in the membership database tables.
aspnet_Users Table
  • Check that User exists i.e. UserName
aspnet_Membership Table
  • IsApproved is set to True
  • IsLockedOut is set to False

Membership Provider Specific Settings Issues

applicationName Attribute

  • Check if applicationName attribute is set for your membership provider in your web.config.
  • If you haven't configured your web.config, then it means your application was using default membership provider settings in machine.config. And applicationName is already set to ‘/’. So it should not be a problem. Still you can check aspnet_Applications table and see if the application name exists.
Note: Check why should you set this?

passwordFormat Attribute

  • There are three settings 0=Clear, 1=Hashed and 2=Encrypted. Compare your web.config andaspnet_Users table to check if the user was created using the same passwordFormat mentioned in your web.config. There were no changes made in development and production. Because sometimes you might create a user using Clear and then decide to change to Hash.

HashAlgorithmType Attribute

  • If your passwordFormat = Hashed (i.e.=1), see there is no change in the type of algorithm used for hashing on development machine and hosting machine. You can quickly check this using the following snippet:
protected void Page_Load(object sender, EventArgs e)
{
Response.Write (Membership.HashAlgorithmType);
}
  • Now if you see they are the same not a problem, but if not then how to go about it. IfHashAlgorithmType is not explicitly set in web.config, the membership provider will use it from element’s validation attribute value. Default value for this is SHA1. So you will have to set this explicitly.
<membership hashAlgorithmType="SHA1">
    <providers>....</providers>
</membership>

Setting Membership Provider in web.config

  • If you are setting custom provider settings in web.config, the bold settings below are to be taken care. Set defaultprovider value. This will be useful when you have more than one provider.
  • The  will help membership provider not to get confused with any other providers inmachine.config or anywhere else.
  • Always set the applicationName attribute.
<membership defaultProvider="AspNetSqlMembershipProvider">
 <providers> 
<clear/> 
<add name="AspNetSqlMembershipProvider" 
type="System.Web.Security.SqlMembershipProvider, 
System.Web, Version=2.0.0.0, Culture=neutral, 
PublicKeyToken=b03f5f7f11d50a3a" 
connectionStringName="LocalSqlServer"
 enablePasswordRetrieval="false" 
enablePasswordReset="true" 
requiresQuestionAndAnswer="true" 
requiresUniqueEmail="false" 
passwordFormat="Hashed" maxInvalidPasswordAttempts="5" 
minRequiredPasswordLength="7" 
minRequiredNonalphanumericCharacters="1" 
passwordAttemptWindow="10" passwordStrengthRegularExpression="" 
applicationName="/ " /> 
</providers> 
</membership> 

Database Related Settings

Connectionstring

  • connectionstringName = LocalSqlServer: If you are having the name of your connectionstringas ‘LocalSqlServer’ in your web.config, don't forget to add the remove tag as shown below:
<connectionStrings> 
<remove name="LocalSqlServer"/> 
<add name="LocalSqlServer" connectionString="....."/> 
</connectionStrings> 
Note: I would always use a unique name instead of ‘LocalSqlServer” for my connectionstring name. This will automatically clear any confusion. For example:
<connectionStrings>
<clear /> 
<add name="MembershipProvider" connectionString="....."/> 
</connectionStrings> 
And then also configure my membership provider as below:
<membership defaultprovider=”..”> 
<providers> 
<clear/> 
<add name="...” 
... 
... 
connectionStringName="MembershipProvider" 
> </membership>

Other Reasons / Checklist / Troubleshooting

Are you using Authenticate event of Login Control

If you are calling Membership.ValidateUser method or any other mechanism to authenticate, don't forget to set e.Authenticate like this as shown below:
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e) { 
if (Membership.ValidateUser(Login1.UserName, Login1.Password)) { 
e.Authenticated = true; } 
else{e.Authenticated = false; }} 
OR

Do you have any empty structure for Login Authenticate event

//Remove any such empty structure for Login Authenticate event
protected void myLogin1_Authenticate(object sender, AuthenticateEventArgs e) 
{ 
} 

Ending Notes

This is all from my experiments and articles and other forums about this error. If there are any errors or any good stuff missing, please point it out so others can find the solution in one place. Many thanks to developers whose experiences helped me write this article, especially the community on www.asp.net forums.

Resources

Check out these forums threads and other links which might help you to understand more.

2015年6月8日 星期一

別再讓財神爺與你擦身而過!十大發財徵兆報你知

奇摩文章



為什麼都聽老師說股票還是跌到屁股痛?買東買西發票沒中過!做牛做馬薪水沒加過?
為什麼財神爺總是擦身而過?天公伯啊~好運何時輪到我?
DailyView聽到你的吶喊,特搜網路流傳的十大發財徵兆,有看有保庇!多留心就多機會!
想錢想瘋了?十大發財徵兆看仔細

NO.10 幫人代挑代買,運氣最好?! 
財神啊財神~世界上最遙遠的距離,是我曾經緊緊握著你卻又拱手讓給別人~
你是否有過這種經驗:幫別人代挑的刮刮樂、代買的購物發票,很常聽說中獎!但輪到自己幫自己買時,NO速!沒有!中獎機率就是哩若-零! 
在此分享本編看過最翹楚的案例-買了2張刮刮樂走出店門,朋友請他再幫買1張;只因懶得再進去,網友選擇把手上其中一張刮刮樂賣給友人,殊不知,賣掉的那一張就是。

NO9. 踩到黃金,狗屎運來了 
踩到狗屎怎麼辦?先別管啦~只要沒大坨到會滑倒,手刀跑去買張刮刮樂先!
莫說咱們鄉愿,雖然狗屎運的來源已不可考,但如真能把踩到狗屎的幹臭,轉化為迎富帶財的狗屎運,也算是現代人的小確幸之一;所以,在遍地黃金的寶島,就算網路上的討論呈現五五波(一派說別傻了踩到屎就是衰呀、一派說Hey那天刮中了1千元就是因為我踩到狗屎啦),「踩到黃金象徵要發財了」這件事,當然是寧可信其有啊!
這麼想,至少當下的心情也會舒坦些吧!(似乎是跟碎碎平安有點兒異曲同工的民間偏方呢)

NO8. 最後一張刮刮樂最旺! 
整本只剩一張的刮刮樂、全店就剩一張的刮刮樂、又或是別人挑剩的刮刮樂,還有讓賴清德賴神摃龜的那本刮刮樂,都是江湖傳言不可放過的好物!有網友分享:剩下來的最後一張刮刮樂,等的就是你呀~都走進店裡了,不帶走它說得通嗎?
至於賴神在去年過年期間摃龜的那本刮刮樂,導致接在市長後面的7位客人通通中獎,據悉已在坊間掀起一股跟著賴神刮刮樂的熱潮!(咦?台南市府沒有這種公開行程嗎?太可惜了!)

NO7. 動物占卜準準準 
想當年世足賽火熱的時候,素以理性、文明、紀律著稱的德國人,可是眼巴巴地盯著他們水族館裡的章魚哥保羅,祈求這隻軟體動物門頭足綱八腕目提供些許德國坦克稱霸的跡象!
你看看,阿兜仔碰上運動賽事,都不問選手問軟絲動物了;只是請動物們稍微暗示可能會中的刮刮樂尾數號碼,合理吧?更何況我們還有職業等級的神鳥、神龜、神牛、神貓呢~更曾有好心人在路上救起小烏龜後,刮中1萬元,根本是浦島太郎現代版哪。

NO6. 氣足氣旺運氣來! 
身為一位鍵盤命理學家,既不會通天眼也不會觀落陰,要如何知道自己的氣場足不足?旺不旺?
來來來~據某些網友說法,生氣怒買的刮刮樂和彩券總是特別容易中!大概因為生氣就是一種很明顯的氣場吧!
此外,民間相傳陽氣會在端午這一天達到最盛,端午節這天的「午時水」還能避災驅邪呢!灌下午時水,抹點雄黃擦點艾草~頭獎500萬的刮刮樂我來了!

NO5. 眼皮狂跳好運到 
雖然醫生告訴我們:疲勞、眼睛乾澀或鉀磷不平衡等,都可能是眼皮狂跳的原因,但愚夫愚婦如我們(好啦只有我),除非眼皮狂跳個幾週,否則都不會想去看醫生吧!
不管是迷信也好,恰巧也罷,網路上鄉民自陳因眼皮狂跳而中獎的案例可不少;而且就算跳的是右眼皮(古云:左眼跳財右眼跳災),買張刮刮樂也算是花錢消災啊~(我們實在是很懂精神勝利法的民族呢!)

NO4. 經過財神家,順手帶財走 
走過路過不要錯過的,除了跳樓大拍賣外,還有你可能擦身而過的好運!到底該不該在固定的地方買刮刮樂或彩券?其實是青菜蘿蔔各有所愛,不過網路上因為路過順手買而中獎的例子不在少數,甚至還有人只是經過問路順手帶張刮刮樂走,就中了1百萬呀!!! 這應該是達到了10種徵兆一次滿足的境界吧!

NO3. 娶妻前、生子後最夯! 
小編超怨嘆,為何每次尾牙春酒的抽獎,大獎不是被快結婚的抽走,就是被剛生完小孩的抱走~
當初發明「娶妻前生子後運勢會旺」這個觀念的老大人,鼓勵生育創意標語的獎金應該頒給他才是呀!畢竟礙於觀感,婚可能無法常常結,小孩卻可以年年生呢。

NO2. 童言童語是中獎指標! 
小孩的童言童語好天真、好可愛,更可能蘊含著宇宙中心難解的謎底,與刮刮樂尾數號碼的奧秘!
想利用寶寶無意中透露的玄機試手氣,就跟任何投資行為一樣有風險,因為就連親爸親媽也分不清他剛剛說的是到底是「借衛生紙」還是「結婚生子」啊~
阿不擱,未滿18歲者不得購買刮刮樂和彩券喔!可別因為囝仔屁股三把火燒騰騰就使喚小孩去買餒!

NO1. 夢的暗示最靈驗 
覺得新聞報導的中獎故事總是離奇了些、懸乎了點嗎?不如看看南韓企劃財政部彩券委員會公布的調查吧:
南韓彩券頭獎中獎人有近五成有過「夢中顯靈」奇妙經驗。
這才是真正的都市傳說啊~而且到底要執行什麼樣的SOP才可以請周公來顯靈呢?誠摯希望調查單位可以再寫清楚好讓我們有個圭臬啊!
相較之下,台灣人的夢就多元多了,像是夢見財神爺、裸女、蛇、狗、火和繩子…等等,竟然還有神人整理出夢的密碼讓大家查詢對照,至於準不準?來,跟我一起1秒鐘唸完:投資一定有風險基金投資有賺有賠申購前應詳閱公開說明書!

2015年5月20日 星期三

2015年5月13日 星期三

使用Login控制項

資料來源:
http://www.dotblogs.com.tw/a93701011/archive/2015/01/30/148319.aspx
https://msdn.microsoft.com/zh-tw/library/ka5ffkce(v=vs.110).aspx

https://msdn.microsoft.com/zh-tw/library/1d3t3c61%28v=vs.85%29.aspx
https://msdn.microsoft.com/zh-tw/library/ka5ffkce(v=vs.110).aspx

//取得或設定在登入嘗試成功時顯示給使用者之頁面的 URL。
Login1.DestinationPageUrl = "~/HRMS/Default.aspx";
//將已驗證的使用者重新導向回到原來要求的 URL 或預設 URL。
FormsAuthentication.RedirectFromLoginPage(Login1.UserName, true);
 //已經過驗證
e.Authenticated = true;
Session["UserId"] = "user";
Session["IsLogin"] = "OK";

2015年5月3日 星期日

無聊捏捏此穴道,你會發現「近視」漸漸不見了


http://www.cmoney.tw/notes/note-detail.aspx?nid=29685

平常工作讀書,眼睛越來越差!


在這個時代,大家多用電腦工作與讀書,
平時休閒也常用到智慧型手機,
不知不覺中,視力越來越差。
 想要顧好要用一輩子的眼睛,就繼續看下去吧...
 小心近視偷偷纏上你!
 我們面前的這個世界越豐富多彩,
吸引我們眼球的東西就越多,
用眼的地方也越來越多,
所以眼鏡就成了許多人的「貼身伴侶」——走哪帶哪。
 近視帶給人的是一個模糊的世界,
因此好多人不惜重金去醫院做近視矯正治療,
也有些人為了美麗去佩戴各色各樣的「美瞳」隱形眼鏡,
或者是用雷射一勞永逸。
也有人覺得近視已經成了家常飯,
沒什麼大不了的,戴上眼鏡也就算了。
所以,近視還真不能忽視,
你忽視了它,它就會趁你不注意,悄悄纏上你。
 

保健與預防方法


針對疾病:近視
適宜人群:此症患者皆適宜

操作方法:
用大拇指和食指同時按摩後溪穴,
每次5分鐘,常年堅持。


中醫對於近視的觀點

缺少陽氣補充,眼睛自然差


其實,近視是西醫的說法,
在中醫裡近視被稱為「能近怯遠證」
或者稱為「近覷」。
它的發病原因,多因過度用眼,
損傷肝血,眼睛裡的經絡不通,
失去正常的舒張功能造成的,
最顯著的症狀就是視近清楚,視遠模糊。

俗話說,過猶不及。
用眼也是同樣的道理,
我們的眼睛需要靠陽氣來補充和滋潤,
僅僅是眼睛疲勞,還不足以造成近視。
真正導致近視的,
是眼睛缺少陽氣滋潤時還過度疲勞。


同一姿勢工作,壓抑了陽氣流動


當我們長期保持同一姿勢伏案工作或學習的時候,
上體前傾,頸椎緊張了,首先壓抑了督脈,
因為督脈總督一身的陽氣,
壓抑了督脈也就是壓抑了全身的陽氣,
陽氣不足了,就沒辦法補充到眼睛,
眼睛的正常舒張功能被抑制,近視也就容易發生。

既然我們知道了近視發生的原因,
就可以找出正確的穴位來解決,這個穴就是後溪。
 這個穴道,疏通了陽氣!
 後溪穴是小腸經上的一個穴,
把手握拳,掌指關節後橫紋的盡頭就是該穴。
 也就是大家握拳頭的時候,
在稱為「感情線」的那條紋的盡頭就是後溪穴。
這個穴是奇經八脈的交會穴,
它通督脈、瀉心火、壯陽氣、
調頸椎、利眼目、正脊柱。
 前面說了,近視的原因是由於
長期的伏案工作而壓迫了督脈,抑制了陽氣發散,
而這個後溪穴正好可以壯陽氣,
陽氣補充足了,眼睛的舒張功能又能正常發揮了,
近視也就不會再發生。

按摩後溪穴的時候,最好用大拇指和食指
同時對著後溪穴發力,
由於手上的穴位比較敏感,
按摩的時候力度要合適,
不要過重而傷及手上的皮膚。

按摩後溪穴可以調整長期伏案或在電腦前學習和工作
對身體帶來的一切不利影響,
只要堅持,這個穴位不僅能為你解決當下的煩惱,
還會在將來為你帶來意想不到的收穫。
 按摩後溪穴的小訣竅
 說到刺激後溪穴,我這裡還可以告訴大家一個小訣竅,
我們伏案久了,或者用電腦一段時間。
休息一下,將手解放出來,
讓雙手的後溪穴抵在桌沿或鍵盤上,
來回滾動,或揉一揉,



每次刺激3~5分鐘,每個小時刺激一次就足夠了。
這樣的小動作,不僅不耽誤工作,
還能有保護眼睛和頸椎、腰椎的作用,何樂而不為呢?

經常在電腦前工作的人,
不妨每天都可以試一下按摩後溪穴的動作,
堅持一天這樣做下來,
到了下班的時候腰不會酸、脖子不會累,
眼睛也不會疲勞。


每天堅持這麼做下去,

挺直彎曲的腰椎頸椎,

同時,你會發現,

眼睛看東西也比以前清楚很多唷!