简体   繁体   English

ASP.NET MVC4 WebSecurity.ConfirmAccount(字符串令牌)的long到int转换异常

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

This seems to be a confusion to me. 这似乎让我感到困惑。 I'm working with MVC4 Simple membership just to help automate my Account process. 我正在使用MVC4 Simple成员身份只是为了帮助实现我的帐户流程自动化。 all seems ok except when i invoke the WebSecurity.ConfirmAccount(string token) and WebSecurity.ResetPassword(string token, string newPassword) methods. 除了我调用WebSecurity.ConfirmAccount(string令牌)和WebSecurity.ResetPassword(string令牌,string newPassword)方法时,其他一切看起来都不错。 both method throw and exception of long to in conversion error when passed with the correct token generated for the user but execute without error and return false when passed with the wrong token. 当使用为用户生成的正确令牌传递时,方法抛出和long to in转换异常均会出错,但执行时不会出错,并且使用错误的令牌传递时,返回false。 Am i making any mistake? 我有什么错误吗?

You cannot convert type long to int because long holds 64 bits from memory and int holds 32 bits from memory. 您不能将long类型转换为int类型,因为long从内存中保留64位,而int从内存中保留32位。 Trying to convert long to int will therefore cause an exception. 因此,尝试将long转换为int将导致异常。

It sounds like your UserId column was created as a bigint rather than an int . 听起来您的UserId列是作为bigint而不是int创建的。 The WebMatrix.WebData.SimpleMembershipProvider expects that column to be an int : WebMatrix.WebData.SimpleMembershipProvider希望该WebMatrix.WebData.SimpleMembershipProvider int

https://github.com/ASP-NET-MVC/aspnetwebstack/blob/master/src/WebMatrix.WebData/SimpleMembershipProvider.cs#L434 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