简体   繁体   中英

VS2010 MVC3 - Spark not showing in View Engine dropdown

I am in the process of converting a good sized asp.net 4 site to MVC3 and I am having trouble with the helper functions in razor partial views. So I wanted to try Spark but after using NuGet to install Spark in my project I don't see how to create a Spark view.

I am assuming that Razor and Spark will co-exist in the same project? If that is not true, then that is probably my problem.

When I treid to create a new view I expected to see Spark in the View Engine drop down on the Add View dialog. Only razor and aspx show up.

I have restarted vs2010 several times now and I shouldn't need to reboot.

Any suggestions?

You need to register Spark View Engine templates.

After installing Spark using NuGet Package Manager follow the below steps:

Step 1 : Navigate to the following path and create a folder with name= Spark . Spark specific templates must be copied into Spark folder. C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\Common7\\IDE\\ItemTemplates\\CSharp\\Web\\MVC 4\\CodeTemplates\\AddView

Step 2 : Create an xml file with in Spark folder. The name of the XML file must be "ViewEngine.xml" and must contain the following xml content.

<?xml version="1.0" encoding="utf-8" ?>
<ViewEngine DisplayName="Spark" 
  ViewFileExtension=".spark" 
  DefaultLayoutPage="~/Views/Shared/_Layout.spark" 
  PartialViewFileExtension=".spark" />

Now, right click on any controller action method and select Add View from the context menu. Now you should able to see the, Spark view engine in the list.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM