简体   繁体   English

添加视图上下文菜单项已消失

[英]Add View context menu item is gone

I am going through Music Store tutorial (ASP.NET 3/Razor). 我正在浏览音乐商店教程(ASP.NET 3 / Razor)。 After I have created the Home controller and Index action, I have right-clicked everywhere in Index action body (and declaration) and "Add View" does not show up. 在我创建了Home控制器和Index操作之后,我在Index action body(和声明)中的任何地方都右键单击,并且“Add View”没有显示出来。

I have tried Ctrl+M, Ctrl-V but it says this combination "is bound to command (Add View...) which is not currently available.". 我已经尝试过Ctrl + M,Ctrl-V,但它说这个组合“绑定到命令(添加视图...),这是当前不可用的。”

Note: This is VS 2010; 注意:这是VS 2010; I had installed NDjango NuGet package which I thought caused this. 我安装了NDjango NuGet包,我认为是这个。 But even after uninstalling that package the problem remains. 但即使在卸载该软件包之后问题仍然存在。

Not sure if you were upgrading a website project from a previous version, but what I did was add {E53F8FEA-EAE0-44A6-8774-FFD645390401}; 不确定您是否从以前的版本升级网站项目,但我做的是添加{E53F8FEA-EAE0-44A6-8774-FFD645390401}; to the list of ProjectGuids in the project file itself (you need to unload the project, make the edit, and then reload the project. 到项目文件本身的ProjectGuids列表(您需要卸载项目,进行编辑,然后重新加载项目。

That worked for me. 这对我有用。

I created another MVC 3 project and Add View menu item was available. 我创建了另一个MVC 3项目,并且可以使用“添加视图”菜单项。 I had not the time to uncover resolutions so re-created the project from ground up; 我没有时间发现决议,所以从头开始重新创建项目; and It worked! 它工作了! I don't know re-installing MVC 3 has any effect, but this seems to be the solution. 我不知道重新安装MVC 3有什么影响,但这似乎是解决方案。

I had the same problem, but when I look more closely, I saw that action method (in the case of music store tutorial HomeController.Index) returns string. 我遇到了同样的问题,但是当我仔细观察时,我看到了那个动作方法(在音乐商店教程HomeController.Index的情况下)返回字符串。 Modify method to return ActionResult and then Add View menu item will be available. Modify方法返回ActionResult,然后Add View菜单项将可用。

I have also faced the same issue and I read a post found here: 我也遇到了同样的问题,我在这里发了一篇文章:

http://www.techiesweb.net/how-to-get-add-view-add-controller-menus-in-solution-explorer-when-converting-existing-asp-net-web-for-project-to-mvc/ http://www.techiesweb.net/how-to-get-add-view-add-controller-menus-in-solution-explorer-when-converting-existing-asp-net-web-for-project-to- MVC /

Which helped me alot and i want to share it for you guys. 哪个帮了我很多,我想分享给你们。 Hope this will help you alot. 希望这会对你有所帮助。

如果控制器中的函数未返回ActionResult,则上下文菜单将不显示“添加视图”。

Have you tried reinstalling the MVC3 bits? 您是否尝试重新安装MVC3位? I guess that's what adds the Add View and Goto View context menu items. 我想这就是添加Add View和Goto View上下文菜单项的原因。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM