How can add controller in ASP.NET MVC6 beta5 project?

耗尽温柔 提交于 2019-12-01 09:39:35

Prior to MVC 6.0 the notion of an MVC Controller and a Web API Controller were somewhat different. To the untrained eye, they looked similar but they did behave differently and were using different classes.

Hence why when you clicked the Controller… option, you had the ability to choose between an MVC Controller and/or a Web API Controller.

As of MVC 6.0, both MVC and Web API controllers have now been unified. They are now exactly the same thing and are using the same classes.

So you don’t really have the need to choose between an MVC Controller and a Web API Controller.

Simply click the Add New Item which in turn will open the Add New Item dialog.

From the Add New Item dialog in the top right search textbox, enter Controller.

You’ll be able to select the MVC Controller Class template.

Who knows...maybe by the time they ship the final product, they’ll bring it back but at least for now, this shouldn’t be a show stopper.

EDIT: For the scaffolding stuff, perhaps this link might help.

to solve this go to project.json then add the following dependency: "Microsoft.Extensions.CodeGenerators.Mvc": "1.0.0-rc1-final"

then you should be able to right click controllers folder and see the new controller button appear

I am facing the same issue for visual studio 2015 community edition, followed following steps and restarted visual studio. It resolved my issue

  • 1)Open VS2015=>TOOLS=>Customize.
  • 2)Select Commands.
  • 3)Select Context menu.
  • 4)Select Project and Solution ContextMenus|Folder|Add.
  • 5)Check that 'Controller' appears.
  • 6)IMPORTANT -Move up Controller item to the top.
  • 7)Restart visual studio
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!