Where is the class ManageUserViewModel?

五迷三道 提交于 2020-01-02 03:27:11

问题


I have created a project using ASP.Net MVC 5, EF 6 and .Net 4.5.1 At some point I needed to change the namespace that the project is in, from "MyTestProject" to "MyRealProject".

After making those changes throughout the web site I now get several errors in a couple of my views. _ChangePasswordPartial.cshtml can't find "@model Microsoft.AspNet.Identity.ManageUserViewModel" any longer and _SetPasswordPartial.cshtml can't find "MyRealProject.ManageUserViewModel"

No where in the project can I find a file that contains the class ManageUserViewModel. Before I changed the namespace it was found but now it isn't. Why? Where did it go and how do I fix it?


回答1:


Found out it's a known problem: http://blogs.msdn.com/b/webdev/archive/2014/08/04/announcing-new-web-features-in-visual-studio-2013-update-3-rtm.aspx

  1. When creating a default C# ASP.NET Web Application from MVC, WebAPI or SPA template with individual authentication, generated Views\Account\ _SetPasswordPartial.cshtml and _ChangePasswordPartial.cshtml files contain invalid model.

In file _SetPasswordPartial.cshtml,

@model .Models.ManageUserViewModel Should be changed to: @model .Models.SetPasswordViewModel

In file _ChangePasswordPartial.cshtml,

@model Microsoft.AspNet.Identity.ManageUserViewModel Should be changed to: @model .Models.ChangePasswordViewModel

Similar problems exist for generated VB projects as well.

In file _SetPasswordPartial.vbhtml,

@ModelType ManageUserViewModel Should be changed to: @ModelType SetPasswordViewModel

In file _ChangePasswordPartial.vbhtml,

@ModelType ManageUserViewModel Should be changed to: @ModelType ChangePasswordViewModel

Also posted it here:https://stackoverflow.com/a/27687882/1071698. I don't know what the rules with duplicate questions and answers, please edit as necessary.




回答2:


_ChangePasswordPartial.cshtml should use something like

@model MyRealProject.Models.SetPasswordViewModel

Then make sure in the models folder AccountViewModels.cs

The namespace is updated to MyRealProject.

Hope that helps.




回答3:


CRTL + SHIFT + F , then type in "class ManageUserViewModel" , just that simple

make sure it is set to search entire solution , and it will find the class you are looking for



来源:https://stackoverflow.com/questions/26849642/where-is-the-class-manageuserviewmodel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!