ASP.NET MVC4 WebSecurity.ConfirmAccount(字符串标记)的长到int转换异常

时间:2015-02-02 14:30:59

标签: c# asp.net asp.net-mvc asp.net-mvc-4 token

这似乎让我感到困惑。我正在使用MVC4简单会员资格,以帮助自动化我的帐户流程。一切似乎都没问题,除非我调用WebSecurity.ConfirmAccount(字符串标记)和WebSecurity.ResetPassword(字符串标记,字符串newPassword)方法。当传递给用户生成的正确令牌但是执行没有错误并且在使用错误令牌传递时返回false时,方法抛出和转换为long的异常转换错误。我有任何错误吗?

2 个答案:

答案 0 :(得分:1)

您无法将类型long转换为int,因为long在内存中保留64位,而int在内存中保留32位。因此,尝试将long转换为int会导致异常。

答案 1 :(得分:0)

听起来您的UserId列已创建为bigint而不是intWebMatrix.WebData.SimpleMembershipProvider期望该列为int

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