我使用 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 http://blogs.msdn.com/b/webdev/archive/2014/08/04/announcing-new-web-features-in-visual-studio-2013-update-3-rtm.aspx
- 当使用单独身份验证从 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 https://stackoverflow.com/a/27687882/1071698。我不知道重复问题和答案的规则是什么,请根据需要进行编辑。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)