Context menu to Add Controller/View missing

前端 未结 17 1028
时光说笑
时光说笑 2020-11-28 06:04

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

相关标签:
17条回答
  • 2020-11-28 06:27

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

    {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}
    
    0 讨论(0)
  • 2020-11-28 06:28

    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.

    0 讨论(0)
  • 2020-11-28 06:29

    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

    0 讨论(0)
  • 2020-11-28 06:31

    For people using MVC 5, add this key

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

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

    0 讨论(0)
  • 2020-11-28 06:32

    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

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