开发者

How to write an MVC3 Project Template that will offer option Razor or .aspx views

开发者 https://www.devze.com 2023-02-06 16:40 出处:网络
I have written two separate project templates to create MVC3 projects (both based on the standard Microsoft template, but with additional controllers/views of my own)- one with ASPX views, and the oth

I have written two separate project templates to create MVC3 projects (both based on the standard Microsoft template, but with additional controllers/views of my own) - one with ASPX views, and the other with Razor views.

But, rather than have two separate templates, I would rather mimic the way that the Microsoft MVC3 template works, which offers both view engine options, selected in a second dialog. I know that this is done with a Wizard, but I can't find the Wizard in the MVC source code (which I've downloaded). Does anybody know where to开发者_运维百科 find the Wizard, or have other helpful suggestions? Thanks.


The custom MVC New Project dialog exists in Microsoft.VisualStudio.Web.Mvc.3.0.dll. We do not ship the source code for that assembly.


I used the Export Template Wizard to create an ASP.NET MVC3 Project Template of my own. This worked OK, but did not offer the same options that Microsoft ships with their Visual Studio MVC assembly. I also ran into an issue where the strongly-typed views were not being updated with the correct namespace. They were keeping the namespace of my original project, while the Controllers and Model was correct.

We would love to have the source code made available for MVC 3 Project Templates!

Here is the Wizard I used. It definitely comes in handy. http://visualstudiogallery.msdn.microsoft.com/57320b20-34a2-42e4-b97e-e615c71aca24/


Phil Haack has documented how to create a custom MVC3 project template that will appear inside that wizard (as opposed to a normal project template that won't)

haacked.com/archive/2011/06/06/creating-a-custom-asp-net-mvc-project-template.aspx

If you follow that process you'll only end up with razor as the possible view engine. To get other view engines, you need to expand the reg files to list spark etc. Details on doing that are provided in this stack overflow answer:

Add custom viewengine to New project dialog?

0

精彩评论

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

关注公众号