divinci
divinci

Reputation: 23159

Mixing MVC and Webforms - Displaying BOTH Context Menus

I have added MVC4 to an ASP.NET Webforms project in Visual Studio 2010.

I changed the .csproj's project type to that of an MVC4 project as detailed here: Context menu to Add Controller/View missing to give me the MVC specific context menus.

Now the ASP.NET Webforms context menus (such as add 'UserControl') are gone.

How can I hack VS2010 to give me both the MVC4 and ASP.NET context menus for a given project?

Upvotes: 2

Views: 397

Answers (2)

Amirhossein Mehrvarzi
Amirhossein Mehrvarzi

Reputation: 18954

Since the IDE is based on working in single mode, It seems we have 2 ways:

  1. Attempt to use a configuration that is done an OR action between two project types, so we have both of them, but lack of true functionality is demanded :(
  2. Write some lines of C++ code to change configuration immediately (based on tip here), so you have a switcher application to run when you want :)

Upvotes: 0

Dai
Dai

Reputation: 155360

In short and officially: no, this is not possible (disclaimer: I'm a software engineer at Microsoft who used to work on Visual Studio + Blend, but now Internet Explorer).

In Visual Studio, a project only has a single type, and the "ASP.NET Web Application" (WebForms) and "ASP.NET MVC Application" (ASP.NET MVC) are two different project types - they're very similar and share common features, but are still different types.

The MVC project type does not have UserControls and other Items in the Add New Item dialog or context-menus because they're largely irrelevant and wouldn't work as you expect them to (granted, it is possible to have WebForms (and not just using .aspx files as Views)) but I don't think it's a good application-design decision.

Unofficially... the items that appear in the Add New Item dialog are specified in the registry. This is documented here: https://msdn.microsoft.com/en-us/library/bb165141.aspx however this information is intended for developers of new project types, rather than allowing users to modify their own (and certainly you're at risk of breaking your VS if we release another update which makes assumptions about how your Add New Item templates are configured).

If you want to do it this way - go ahead, but be careful, and make a note of everything you do so you can undo it.

Upvotes: 3

Related Questions