ManageUserViewModel类在哪里?
我使用ASP.Net MVC 5,EF 6和.Net 4.5.1创建了一个项目。在某些时候,我需要更改项目所在的命名空间,从“MyTestProject”到“MyRealProject”。
在整个网站上进行了这些更改后,我现在在几个视图中遇到了一些错误。 _ChangePasswordPartial.cshtml再也找不到“@model Microsoft.AspNet.Identity.ManageUserViewModel”而且_SetPasswordPartial.cshtml找不到“MyRealProject.ManageUserViewModel”
在项目的哪个位置,我找不到包含类ManageUserViewModel的文件。 在我更改命名空间之前,它已被发现,但现在却没有。 为什么? 它去了哪里,我该如何解决?
发现它是一个已知的问题: http : //blogs.msdn.com/b/webdev/archive/2014/08/04/announcing-new-web-features-in-visual-studio-2013-update-3-rtm的.aspx
- 从具有单独身份validation的MVC,WebAPI或SPA模板创建默认C#ASP.NET Web应用程序时,生成的Views \ Account \ _SetPasswordPartial.cshtml和_ChangePasswordPartial.cshtml文件包含无效模型。
在文件_SetPasswordPartial.cshtml中,
@model .Models.ManageUserViewModel应更改为:@model .Models.SetPasswordViewModel
在文件_ChangePasswordPartial.cshtml中,
@model Microsoft.AspNet.Identity.ManageUserViewModel应更改为:@model .Models.ChangePasswordViewModel
生成的VB项目也存在类似的问题。
在文件_SetPasswordPartial.vbhtml中,
@ModelType ManageUserViewModel应更改为:@ModelType SetPasswordViewModel
在文件_ChangePasswordPartial.vbhtml中,
@ModelType ManageUserViewModel应更改为:@ModelType ChangePasswordViewModel
也发布在这里: https : //stackoverflow.com/a/27687882/1071698 。 我不知道具有重复问题和答案的规则,请根据需要进行编辑。
_ChangePasswordPartial.cshtml应该使用类似的东西
@model MyRealProject.Models.SetPasswordViewModel
然后确保在模型文件夹AccountViewModels.cs中
命名空间更新为MyRealProject
。
希望有所帮助。
CRTL + SHIFT + F,然后输入“类ManageUserViewModel”,就这么简单
确保将其设置为搜索整个解决方案,它将找到您要查找的类
- 转换/修改asp.net标识中的声明2
- Windows 10更新后,MVC应用程序中断
- 有没有更有效的方法来处理C#ASP.NET上的亚马逊产品广告API(特别是MVC 5)?
- 具有键“CategoryId”的ViewData项的类型为“System.Int32”,但必须是“IEnumerable ”类型的?
- 如何使用InvariantCulture仅渲染某些特定的模型字段,而其余的则继续使用用户文化?
- 在Razor视图中使用“nameof”运算符
- 使用MVC 5 RouteArea属性时,无法找到默认区域视图
- 使用dbcontext的正确方法(全局或传递为参数?)
- 在ASP.NET MVC中使用重定向传递复杂对象?