How can add controller in ASP.NET MVC6 beta5 project? - asp.net-mvc

i'm install Visual Studio 2015 final release and create mvc6 beta5 project (by default template).
Trying add controller as in mvc 5.2 (also in vs2015 final release):
but, in mvc6 beta5 project this menu missing:
1. How solve the problem?
UPD
2. Is it possible add mvc6 controller with generate views?

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

Related

Add Area Option for Mvc application missing in VS2015

I have an vs 2015, i am working on mvc application but when i tried to add area i cann't see add area option any where in those option, but i could able to add those in 2012 version. And also in case of adding controller to the project i can't add normal MVc controller to my project it's giving only option for adding Web api controller and and its types, how should i make this work ? sholud i install some scaffolder templates or what ? can i get the solution for this issue ?? , thanks in advance.
For VS 2019
Press right click on ur project
2. Add
3. New Scaffolded Item...
4. MVC 5 Area
Yes, I found the problem that it's my project issue. adn becuase it was a mvc4 project and i am trying to run in vs 2015, it couldn't able to recongnize as right version.
and Updating my project mvc version solved the problem
Ref 1.https://www.asp.net/whitepapers/mvc4-release-notes#_Toc303253806
Ref 2.http://www.codingdefined.com/2015/04/how-to-fix-systemmethodaccessexception.html

Add controller is greyed in Visual Studio Asp.net Core 1.0 MVC

I am following the Microsoft 'first-mvc-app' tutorial from here. When I try to add a controller class to the model folder, I can't add it. The add button is greyed out and doesn't give a reason for it. I followed the tutorial to the T so I think something is different with my setup. I am running Visual Studio 2015 with the latest updates and I am using MVC 1.0 RC2.
You need to Shift-F5 to end debug and it will not be greyed out.
Try filling the forms like "Model Class" by selecting from the dropdown lists instead of directly entering text. This activated the "Add" button in my case.

Visual Studio Update 2015, many options for ASP.NET MVC project missing

I just installed Visual Studio 2015 Update 1, and a lot of the configuration I was used to is missing or different. I'd like to know if these changes are due to something simple (like a package I need to install), or if it's something a little more complex.
I'm mainly using Visual Studio to create MVC apps from scratch, so before the update, I would create an empty MVC app with the "Add core references and folders for MVC" selected. Now, I can only create an empty MVC project with nothing pre-configured, or a fully scaffolded MVC app.
In the empty MVC project, there's no option to "Add Controller" when I right-click the "Controllers" folder I create. However, this option is available in the generated one.
The Add New Item menu is divided into Server-side and Client-side templates for the generated app, but it's divided into Code/Data/General/Web/etc. in the empty app. There's also an option to add an MVC View in the generated app, but there's nothing with Razor for the empty app. No .cshtml intellisense in the empty app, either.
There's a lot of functionality and options missing from the empty app that seem like they have to do with how the app is an MVC app, since they're available for the generated app. Is there a straightforward fix that will allow me to create an MVC app using Razor from an empty template?
Figured it out! I was using the ASP.NET 4.5.2 Empty Template, and choosing the ASP.NET 5 Template solved the problem.

Did VS2013 incorrectly upgrade my project files?

I had a solution that included both an ASP.NET MVC web project and a WebAPI project. The solution was created originally with VS2012, but I recently upgraded it to VS2013.
I just noticed when going to add a controller that I'm not getting the correct options in the right click menu. For instance if I go to the web project and right click the controllers folder, the option to add a controller isn't there. Instead I have add WebAPI controller. It's exactly the opposite for the WebAPI project.
Things seem to build and run ok so far, but it's going to be a pain manually adding things and I'm wondering if something else might break. Any idea why this is happening or how to fix it?
I would guess that project type is different in your csproj. Take a look at this question:
What is the significance of ProjectTypeGuids tag in the visual studio project file
Here is what I have on my machine for c# asp.net mvc project:
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
Take a look at your guids and see what they mean.
You could see the meaning of the different GUID in the register :
•HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\10.0\Projects for
ProjectTypeGuids
•HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\10.0\Packages for
packages reference by some project

Add View dialog does not work in an MVC 5 project that references an F# project

Using Visual Studio 2013, create a new ASP.NET Web Application project using the MVC template. Verify that the Add View dialog functions by right-clicking the "Views\Home" folder and choosing "Add... View".
Now add a new F# Library project to the solution. The Add View dialog should still function correctly.
Now add a project reference from the MVC project to the F# project by right-clicking the References folder, choosing Add Reference, Then browse to Solution...Projects on the left and checking the F# library project that you just added.
At this point, if you right-click the "Views\Home" folder and choose "Add... View" you will get an error in a pop-up alert box instead of the Add View dialog:
There was an error running the selected code generator: 'Object reference not set to an instance of an object.'
Workarounds include, but are hopefully not limited to:
Remove all your references to any F# projects every time you want to add a new view.
Unload any referenced F# projects, but leave the project references in place, every time you want to add a new view.
My questions are:
Are other people seeing this behavior, or is it just me?
Does anyone know of a better work-around than removing references or unloading F# projects?
Does anyone know if Microsoft is already working on fixing this? If not should this be reported to the F# team or the Visual Studio team?
Between this issue and the fact that it is still impossible to use NuGet to add an Entity Framework 6 reference to any F# project, I'm starting to get nervous about Microsoft's level of commitment to the F# language.
Not sure if this will help you but check the version of EntityFramework in your solution. I had two projects within my solution and for whatever reason, the web project had EF 6 and the class library project was EF 6.1. Once I uninstalled EF completely from the solution and reinstalled EF 6.1 on both project, the "Add new view" action started working.
I received the same error message when adding views or controllers in a C# & MVC multi-project solution, using EF 6.1 and VS2013 with Update 3. The problem was because the nuget "packages" folder was marked as read only, because it was checked into source control. I checked the entire folder out, making it editable, and it started working fine, allowing me to scaffold straight from VS.
I also received the error message in a web.api project because I forgot to add the Entity Framework connection string to the web.config (it was using Areas and EF was looking in the Area web.config, not the web.config in the root).

Resources