13

I have an existing WebForms project to which I'm adding MVC pages. I created an MVC project and copied the project type guids.

It works fine, but I can't get Visual Studio to display the "Add Controller" or "Add View" wizards on my controllers and views directories (they're not /Controllers and /Views, they're in /Foo/Controllers and /Foo/Views).

Is it possible to enable the wizards?

3
  • Probably and good luck, but I've always found that those are practically useless as views and controllers aren't much different at all than the regular aspx page and class.
    – user1228
    Commented Oct 21, 2009 at 12:37
  • @Will, if you add this as an answer I'd accept it - I also realized that I'm served just as well by code snippets
    – orip
    Commented Oct 27, 2009 at 7:02
  • Is Foo a simple directory or Area? Commented Apr 23, 2013 at 12:56

7 Answers 7

11

For MVC 3, ProjectTypeGuids should look like the following:

<ProjectTypeGuids>{E53F8FEA-EAE0-44A6-8774-FFD645390401};{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>

(See Upgrading an ASP.NET MVC 2 Project to ASP.NET MVC 3)

1
  • 2
    -1: @orip told that he already changed the GUIDs. Guids are not a problem here. His question is: How to make those context menus appear on different folders and not directly Controller and Views. Commented Jul 6, 2012 at 16:56
6

To get full designer support for hybrid projects you need to add MVC "project type" to in the project file.

Open your project file and replace ProjectTypeGuids tag with

<ProjectTypeGuids>{F85E285D-A4E0-4152-9332-AB1D724D3325};{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>

After that you will see new context menus ("Add View", "Add Area", "Add Controller", etc) in your "old" ASP.NET project

Works for both MVC and MVC 2.

1
  • -1: OP already added those GUIDs you're referring to. His question is how to put those wizards on folders ie. Foo\Controllers and Foo\Views and not to those couple that are in the app root... Commented Jul 6, 2012 at 16:58
5

For MVC 4:

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

I've given up on this. Instead, I have some basic Resharper snippets. Too bad this isn't configurable.

3
  • Can you please tell me what snippets you're talking about here? Because scaffolding still won't work now would it? Commented Jul 6, 2012 at 17:08
  • @RobertKoritnik nothing fancy, just snippets that let me put the controller/view name and have the viewmodel name etc. derived based on my convention, e.g. LoginView -> LoginViewModel.
    – orip
    Commented Jul 8, 2012 at 6:31
  • 1
    Still no solution? I've added some bounty to your question.
    – Johan
    Commented Apr 17, 2013 at 9:43
2

Here is the guid for MVC3 :

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

unload your project, open csproj file and add the GUID to the begining of tag. no extra spaces nor line breaks, then reload the project. Like this

<ProjectTypeGuids>{E53F8FEA-EAE0-44A6-8774-FFD645390401};{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
1

Maybe you could enable them, but why bother? Those wizards are available just two clicks away: right click on the folder, click on Add - New item, then select "MVC View Page" or "MVC Controller Page". They are not in the contextual menu, but they are still quite near... :)

2
  • 1
    (1) I couldn't make the templates appear in "Add -> New Item" in this project [I don't know why], and (2) the "MVC View Page" template under "Add -> New Item" doesn't let me choose a statically-typed view model like the wizard does.
    – orip
    Commented Oct 27, 2009 at 7:00
  • @orip: although it does choose the customized templates of controllers (if you put them in the CodeTemplates folder) it doesn't really help too much with views especially if you do use those scaffolded ones... Commented Jul 6, 2012 at 17:07
1

This issue is resolved. I have a hybrid project and I had the same problem. Could not able to see "Add View/Add Controller" in the context menu. It is now resolved. Please see the following link Context menu to Add Controller/View missing

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.