Context menu to Add Controller/View missing

2019-01-06 11:01发布

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?

16条回答
老娘就宠你
2楼-- · 2019-01-06 11:28

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.

查看更多
爷、活的狠高调
3楼-- · 2019-01-06 11:30

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

查看更多
Anthone
4楼-- · 2019-01-06 11:33

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};
查看更多
相关推荐>>
5楼-- · 2019-01-06 11:33

VS2012 Context menu to Add Controller/View missing

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

UnInstall-Package Microsoft.AspNet.WebApi 
查看更多
Viruses.
6楼-- · 2019-01-06 11:34

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

查看更多
Bombasti
7楼-- · 2019-01-06 11:36

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.

查看更多
登录 后发表回答