devzero
devzero

Reputation: 2680

"add view" in non mvc project visual studio

I have a solution where I have a MVC project containing all my views, and all other front end code. We also have another project (in the same solution) where I have the controllers.

If I add a controller to the mvc project and add a viewresult function to this conroller I can right click on the "return view(viewModel);" and choose "add view".

If I copy this controller to the "non mvc" project, I do not get "add view" in the right click context menu. Is there any way to get this ?

Upvotes: 3

Views: 701

Answers (1)

levelnis
levelnis

Reputation: 7705

Yes - you need to add the MVC ProjectTypeGuid to the project file. Upload the project in Visual Studio and then right-click > Edit project file. Check to see whether you have a <ProjectTypeGuids> tag in your project. It may well be directly beneath the <ProjectGuid> tag. There are 3 guids in my MVC project but I'm not sure exactly which one(s) is/are needed. Start by adding all 3, reload the project, check you have the context menu, and then try removing them one at a time to isolate which is needed. I don't think it will harm the project to leave them all in though. Here's the tag from my project file:

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

EDIT: Not sure whether this will give you the in-view context menu but it will give you the solution explorer, right-click > Add View context menu.

EDIT 2: Yes it will, just tried it.

Upvotes: 1

Related Questions