【发布时间】:2014-12-09 02:00:32
【问题描述】:
设置:
我有一个 MVC 5 应用程序,其中包含许多使用我自己导出的模板创建的库项目。导出的模板运行良好。
我正在使用 ASPNET 标识。我只是使用相关 NuGet 包中提供的 Microsoft Aspnet 身份示例的副本,我已将其编织到导出的模板中。这一直运行良好。
我没有接触过 ASPNET Identity 2 示例中提供的文件。
错误发生在 IdentityConfig.cs 文件中。
由于某种原因,它开始出现一个错误,指出它无法为 System.Web.Mvc 加载文件,因为它找不到版本 5.1.0.0。
因此,我使用 NuGet 来更新 Microsoft.Aspnet.Mvc 包。这安装了 system.web.mvc 的 5.2.2.0 版本,这有效地清除了该错误。
不过……
虽然应用程序已加载,但每当我尝试登录或创建新用户时,都会出现一个新错误(如下所示),基本上表明 ASPNET Identity UserManager 对象为空。
我更新了microsoft.aspnet.identity包,但是在尝试登录或新建用户时仍然出现错误(登录页面显示ok,但是点击登录按钮时出现错误)
在收到有关 system.web.mvc 引用的错误之前,我可以在闲暇时登录并注册用户。
错误:
这是我尝试登录时显示的错误。当我尝试注册新用户时,我得到一个不同的错误,但原因相同:UserManager 对象为空,而它不应该是。
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 324: public async Task<SignInStatus> PasswordSignIn(string userName, string password, bool isPersistent, bool shouldLockout)
Line 325: {
Line 326: var user = await UserManager.FindByNameAsync(userName);
Line 327: if (user == null)
Line 328: {
Source File: c:\Users\[user name]\Documents\Visual Studio 2013\Projects\[My solution]\Models\IdentityConfig.cs Line: 326
问题:
有人知道是什么原因造成的吗?
例如,Microsoft Aspnet Identity 示例代码是否可能需要针对 system.web.mvc dll 的 5.2.2.0 版本进行更新?
注意:恐怕我无法确定或回忆在错误开始发生之前我所做的更改。我已经有一段时间没有从事这个项目了。
【问题讨论】:
标签: asp.net-mvc-5 asp.net-identity-2