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

后端 未结 3 1388
刺人心
刺人心 2021-01-15 00:52

i\'m install Visual Studio 2015 final release and create mvc6 beta5 project (by default template). Trying add controller as in mvc 5.2

相关标签:
3条回答
  • 2021-01-15 01:02

    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.

    0 讨论(0)
  • 2021-01-15 01:16

    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
    0 讨论(0)
  • 2021-01-15 01:21

    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

    0 讨论(0)
提交回复
热议问题