【问题标题】:Where is the class ManageUserViewModel?ManageUserViewModel 类在哪里?
【发布时间】:2014-12-29 19:25:44
【问题描述】:

我使用 ASP.Net MVC 5、EF 6 和 .Net 4.5.1 创建了一个项目 在某些时候,我需要将项目所在的命名空间从“MyTestProject”更改为“MyRealProject”。

在对整个网站进行了这些更改之后,我现在在一些视图中遇到了几个错误。 _ChangePasswordPartial.cshtml 找不到“@model Microsoft.AspNet.Identity.ManageUserViewModel”,_SetPasswordPartial.cshtml 找不到“MyRealProject.ManageUserViewModel”

在项目中我找不到包含类 ManageUserViewModel 的文件。在我更改命名空间之前,它被发现了,但现在没有。为什么?它去了哪里,我该如何解决?

【问题讨论】:

    标签: c# asp.net-mvc asp.net-mvc-5


    【解决方案1】:

    发现这是一个已知问题: http://blogs.msdn.com/b/webdev/archive/2014/08/04/announcing-new-web-features-in-visual-studio-2013-update-3-rtm.aspx

    1. 当使用单独的身份验证从 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 设置密码视图模型

    在文件_ChangePasswordPartial.vbhtml中,

    @ModelType ManageUserViewModel 应改为: @ModelType 更改密码视图模型

    也在此处发布:https://stackoverflow.com/a/27687882/1071698。我不知道重复的问题和答案的规则是什么,请根据需要编辑。

    【讨论】:

      【解决方案2】:

      _ChangePasswordPartial.cshtml 应该使用类似

      @model MyRealProject.Models.SetPasswordViewModel
      

      然后确保在模型文件夹中 AccountViewModels.cs

      命名空间更新为MyRealProject

      希望对您有所帮助。

      【讨论】:

        【解决方案3】:

        CRTL + SHIFT + F ,然后输入 "class ManageUserViewModel" ,就这么简单

        确保它设置为搜索整个解决方案,它会找到你正在寻找的类

        【讨论】:

        • 我已经搜索了完整的解决方案。它在解决方案中不存在。
        猜你喜欢
        • 2018-04-02
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-07-15
        • 2014-07-15
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多