There is no context menu for adding a controller / view

I have included ASP.NET MVC 4 in my existing asp.net website. Both work fine, but I don't see any menus / shortcuts for creating a controller / view in the IDE visual studio environment. Are only ASP.NET MVC templates available?

+52
visual-studio asp.net-mvc visual-studio-2010 asp.net-mvc-4
May 10 '12 at 18:34
source share
16 answers

Are only ASP.NET MVC templates available?

Yes, but you can cheat. The way Visual Studio shows these shortcuts is to look at the type of project, and if he sees that it is an ASP.NET MVC project, he will make them available. But how does he know that this is an ASP.NET MVC project? After all, ASP.NET MVC is an ASP.NET project.

Open the .csproj file and find the <ProjectTypeGuids> node of your ASP.NET MVC 4 project. You will see something like this:

 <ProjectTypeGuids>{E3E379DF-F4C6-4180-9B81-6769533ABE47};{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids> 

Now open the .csproj file of your regular ASP.NET project and simply add the GUID {E3E379DF-F4C6-4180-9B81-6769533ABE47} as the first item in the list (if you do not create the project, you donโ€™t even load it). All this. You will now see ASP.NET MVC-specific context menus in your WebForms project.

+108
May 11 '12 at 6:08 a.m.
source share
โ€” -

GUID Change Step

  • Right-click on a project in Solution Explorer
  • Click upload project
  • Right-click on a project in Solution Explorer
  • Edit project file /projectname.csproj
  • GUID GUID
  • Right-click and select Update Project

In the <ProjectTypeGuids> add any of these GUIDs to the top

 {E3E379DF-F4C6-4180-9B81-6769533ABE47}; {E53F8FEA-EAE0-44A6-8774-FFD645390401}; 
+31
Feb 07 '14 at 4:24
source share

For people using MVC 5 add this key

 {E3E379DF-F4C6-4180-9B81-6769533ABE47}; 

at the beginning. Other teams will not work.

+8
Dec 15 '14 at 11:15
source share

Answer 2 was the right, wrong director

{E53F8FEA-EAE0-44A6-8774-FFD645390401}

is what you need for MVC in VS2010

+3
Nov 16 '12 at 9:23
source share

Do not update your MVC project anything. Fire this command in the Nuget Package Manager console.

Microsoft.AspNet.Mvc Package Update

+3
Nov 05 '15 at 15:55
source share

When you right-click on a project in Solution Explorer, you need to unload the project, edit the project, change the tag using the table below, and then reload the project. Insert the appropriate GUID at the top of the list in the csproj file.

Different GUIDs for different versions of MVC:

 ASP.NET MVC 1 {603C0E0B-DB56-11DC-BE95-000D561079B0} ASP.NET MVC 2 {F85E285D-A4E0-4152-9332-AB1D724D3325} ASP.NET MVC 3 {E53F8FEA-EAE0-44A6-8774-FFD645390401} ASP.NET MVC 4 {E3E379DF-F4C6-4180-9B81-6769533ABE47} ASP.NET MVC 5 {349C5851-65DF-11DA-9384-00065B846F21} 
+2
Sep 22 '15 at 19:02
source share

I had the same problem when opening an MVC project as a website. I reopened the solution through Open โ†’ Project, and this functionality worked as I expected.

+1
Nov 02 '14 at 15:34
source share

I know this is an old post, but I just ran into this switch between VS2013 and VS2012 for the MVC 5 project. The problem was that the version of the MVC template that I used was not installed from the Visual Studio update. VS2012 did not come with MVC5 because it came out after it, so VS2012 needed an update to update the template. Same as VS2010 and MVC4.

In any case, downloading the update from Microsoft solved my problem, because when another version was opened and saved the project, it will disappear again when using the fix above.

Here is a link to update VS2012 MVC5. Make sure you download and install both the tool update and the VS plugin.

http://www.microsoft.com/en-us/download/details.aspx?id=41532

+1
Mar 20 '15 at 16:42
source share

Had the same issue with VS2015 , helped change ProjectTypeGuids content to:

 {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} 
+1
Nov 11 '15 at 20:38
source share

You're right. The presence of these context menu options is of the project / template type.

0
May 10 '12 at 18:36
source share

For older version

 {F85E285D-A4E0-4152-9332-AB1D724D3325} 
0
Feb 26 '15 at 13:58
source share

I missed where I expected it to exist (at the top of the menu, which shows when you right-click on the view folder and click "Add"), but then I found it in the context menu in the "New" section from the template "! I have re-sharpper, I think it happened because of this (also Visual Studio 2012):

enter image description here

0
Jul 10 '15 at 19:14
source share

I am on VS2012 and tried to answer the Dimitrovs (by adding a specific GUID to the ProjectTypeGuids project file). Although this gave me the missing context menu for controller actions, I lacked intellisense on my Razor pages.

It turns out that I lacked the VS tool for the MVC project version I was working on, and installing this toolkit (rather than editing the project file) solved my problems.

Download Page for ASP.NET and Web Tools 2013.1 for Visual Studio 2012

I found this download link from the following blog post:

Announcement of ASP.NET Release and Web Tools 2013.1 for Visual Studio 2012

0
Jan 04 '16 at 23:15
source share

If all else fails (before reinstalling VS2015), you might want to reset VS cache. This worked for me (after repair - DO NOT interfere with GUIDS). Just delete the contents in the folders indicated in this link (it takes about 30 seconds), and then run the command. It takes another 10 seconds. Restart VS and you will see the first user screens in VS. It worked like a charm.

http://blogs.msdn.com/b/willy-peter_schaub/archive/2010/09/15/if-you-have-problems-with-tfs-or-visual-studio-flush-the-user-cache- or-not.aspx

0
Feb 07 '16 at 16:27
source share

This problem can also occur if you just checked a new copy of your solution from your code repository, and NuGet packages, including Microsoft.AspNet.Mvc, have not yet been downloaded. Solution recovery fixes the problem.

0
Nov 07 '17 at 14:35
source share

VS2012 There is no context menu for adding a controller / view

On VS2012 and MVC4, try unistall Web API 5.2 in PM:

 UnInstall-Package Microsoft.AspNet.WebApi 
-2
Jun 01 '15 at 14:45
source share



All Articles