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 ?
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: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.