开发者

"Add Controller" / "Add View" in a hybrid MVC/WebForms ASP.NET application

I have an existing WebForms project to which I'm adding MVC pages. I created an MVC project and copied the pr开发者_JS百科oject 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?


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)


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.


For MVC 4:

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


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


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>


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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜