簡體   English   中英

ASP.NET MVC4 WebSecurity.ConfirmAccount(字符串令牌)的long到int轉換異常

[英]long to int conversion exception with ASP.NET MVC4 WebSecurity.ConfirmAccount(string token)

這似乎讓我感到困惑。 我正在使用MVC4 Simple成員身份只是為了幫助實現我的帳戶流程自動化。 除了我調用WebSecurity.ConfirmAccount(string令牌)和WebSecurity.ResetPassword(string令牌,string newPassword)方法時,其他一切看起來都不錯。 當使用為用戶生成的正確令牌傳遞時,方法拋出和long to in轉換異常均會出錯,但執行時不會出錯,並且使用錯誤的令牌傳遞時,返回false。 我有什么錯誤嗎?

您不能將long類型轉換為int類型,因為long從內存中保留64位,而int從內存中保留32位。 因此,嘗試將long轉換為int將導致異常。

聽起來您的UserId列是作為bigint而不是int創建的。 WebMatrix.WebData.SimpleMembershipProvider希望該WebMatrix.WebData.SimpleMembershipProvider int

https://github.com/ASP-NET-MVC/aspnetwebstack/blob/master/src/WebMatrix.WebData/SimpleMembershipProvider.cs#L434

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM