Context menu to Add Controller/View missing

I have integrated ASP.NET MVC 4 into existing asp.net web site. Both works fine but I don’t see any menu/shortcuts to create controller/view within visual studio IDE. Are those only available to ASP.NET MVC template?

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

Are those only available to ASP.NET MVC template?

Yes, but you could cheat. The way Visual Studio shows those shortcuts is by looking at the project type and if it sees that it is an ASP.NET MVC project it will make them available. But how does it know it is an ASP.NET MVC project? After all ASP.NET MVC is an ASP.NET project.

Open the .csproj file and look for 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 {E3E379DF-F4C6-4180-9B81-6769533ABE47} GUID as first item in the list (if you don’t project does not even load). That’s all. Now you will see the ASP.NET MVC specific context menus in your WebForms project.

Method 2

Step to change the GUID

  1. Right click on the project in solution explorer
  2. Click unload project
  3. Right click again on the project in solution explorer
  4. Edit projectfolder/projectname.csproj
  5. Chagne GUID
  6. Right click and select “Reload Project”

In <ProjectTypeGuids> tag add any of these GUIDs in beginning

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

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

Method 3

For people using MVC 5, add this key

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

in the beginning of . The other guids won’t work.

Method 4

Do nothing just update your MVC project. Fire this command in your Nuget Package Manager console.

Update-Package Microsoft.AspNet.Mvc

Method 5

Answer 2 was correct just wrong guid

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

is what you need for MVC in VS2010

Method 6

By right clicking the project in Solution Explorer, you need to unload the project, edit the project, change the tag using the chart below, and then reload the project.
Paste the appropriate GUID to the front of the list in the csproj file.

The 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}

Method 7

I had the same problem when opened MVC project as Web Site. I reopened solution thru Open -> Project and this functionality worked as I expected.

Method 8

I know this is an old post, but I just ran into this switching between VS2013 and VS2012 for an MVC 5 Project. The issue I had is that the version of the MVC Template I was using wasn’t installed from the Visual Studio update. VS2012 didn’t come with MVC5 as it came out after it, so an update was required for VS2012 to add the template. Same with VS2010 and MVC4 I imagine.

Anyhow, downloading the update from Microsoft resolved my issue as when another version opened and saved the project, it would again disappear when using the fix above.

Here is the link to the VS2012 MVC5 update. Ensure that you download and install both the Tools update and the VS plugin.

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

Method 9

For me it was missing from where I expected it to exist (at the top of the menu which shows when you right click on a view folder and click on ‘Add’), but then I found it at a sub context menu under ‘New From Template’! I have re-sharper installed, I guess it happened because of it (Also Visual Studio 2012):

enter image description here

Method 10

Had the same problem with VS2015, helped changing ProjectTypeGuids content to:

{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}

Method 11

I am on VS2012 and tried Dimitrov’s answer (adding a particular GUID to the project file’s ProjectTypeGuids). While this did give me the missing context menu for the controller actions, I was missing intellisense on my Razor pages.

It turns out I was missing the VS tooling for the version of the MVC project I was working on, and installing this tooling (rather than editing the project file) resolved my issues.

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

I found this download link from the following blog post:

Announcing release of ASP.NET and Web Tools 2013.1 for Visual Studio 2012

Method 12

You are correct. The presence of these context menu options is project type/template specific.

Method 13

For older version

{F85E285D-A4E0-4152-9332-AB1D724D3325}

Method 14

When all else fails (before reinstalling VS2015) you might want to reset VS cache. This worked for me (after repairing – NOT meddling with GUIDS). Just delete the contents in the folders mentioned in this link (takes about 30 seconds), then execute the command. That takes another 10 seconds. Restart VS and you will see the screens of a first-time user 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

Method 15

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

Method 16

Here’s what worked for me with VS 2017.

First check if you’re able to create a new empty MVC project.

If not – this means some components are missing. Launch Visual Studio Installer (typicall sits in C:Program Files (x86)Microsoft Visual StudioInstallervs_installer.exe but you cna just hit “start” and start typing “visual studio installer”)

Lick “modify” and simply re-run it with all existing components checked.

Just make sure “ASP.NET Web development” is checked.

Method 17

You might have opened the project as folder type which limits the visual studio IDE to limit certain GUID options, so load your project solution.

It should work. Add view or Add controller should be available as soon as you right click on the ActionResult or inside controller.

Method 18

VS2012 Context menu to Add Controller/View missing

In VS2012 & MVC4 try unistall Web API 5.2 in PM:

UnInstall-Package Microsoft.AspNet.WebApi


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x