Adding a view folder to config

95 views
Skip to first unread message

Jordan

unread,
Nov 30, 2011, 5:43:00 AM11/30/11
to Spark View Engine Dev
Hi,

It is probably me being stupid but it is there some information
missing in the "Adding a view folder to config" section here
http://sparkviewengine.com/documentation/viewlocations ?

If I just want to add one filesystem directory (called "Reports") what
should I do?

The suggested possible attributes of the "add" xml tag are: name,
folderType, type, constuctor-param-names, and subfolder. Which one of
these should I use to specify the folder name?

The examples on the same page use assembly, resourcePath, and
virtualBaseDir attributes which aren't in the list above, which makes
me wonder if there are some other undocumented ones?

Apologies if I'm just being dozy.

regards,
Jordan.

franc

unread,
Nov 30, 2011, 8:15:04 AM11/30/11
to Spark View Engine Dev
Hi Jordan,

Try this:

SparkSettings.AddViewFolder(ViewFolderType.FileSystem,
viewFolderParameters)
where viewFolderParameters in the physical location of your views

Regards,
Franc

Jordan

unread,
Nov 30, 2011, 11:03:10 AM11/30/11
to Spark View Engine Dev
HI Franc,

Many thanks for the reply. Iim in a web app so I've realised I need
ViewFolderType.VirtualPathProvider, but I still don't understand why
we need to pass in dictionary. Whats the "key" and whats the "value"?

ps - also, does the xml in web.config not work?

cheers,
Jordan.

Jordan

unread,
Dec 1, 2011, 6:52:51 AM12/1/11
to Spark View Engine Dev
Hi everyone,

Sorry to spam the list but even after Francs reply I'm still none the
wiser. Anything I try in code or XML either results in the new folder
not being added, or I get an IndexOutOfRangeException when trying to
hit any page in the webapp.

What I am trying to do is add a directory under Views called
"Reports" (ie ~/Views/Reports) that spark will look in when trying to
resolve a view.

cheers,
Jordan.

Jordan

unread,
Jan 3, 2012, 12:24:44 PM1/3/12
to Spark View Engine Dev
> What I am trying to do is add a directory under Views called
> "Reports" (ie ~/Views/Reports) that spark will look in when trying to
> resolve a view.

Bump.... continues conversation with self ;)

I never solved this, can anyone offer any help?

regards,
Jordan.

franc

unread,
Jan 4, 2012, 10:41:23 AM1/4/12
to Spark View Engine Dev
Hi Jordan,

I have never tried it via xml, this is what your code should look
like:

string templatePath =
this.httpContextProvider.Current.Server.MapPath("~/Views/Reports/");
var viewFolderParameters = new Dictionary<string, string>
{ { "basePath", templatePath } };
SparkSettings settings = new SparkSettings();
settings.AddViewFolder(ViewFolderType.FileSystem,
viewFolderParameters);
....

Let me know if that helps

Jordan

unread,
Jan 4, 2012, 11:15:34 AM1/4/12
to Spark View Engine Dev
Thanks Franc, unfortunately now I get the following error whenever I
try to access any page in the application:

[IndexOutOfRangeException: Index was outside the bounds of the array.]
System.Web.HttpApplication.get_CurrentModuleContainer() +36
System.Web.PipelineStepManager.ResumeSteps(Exception error) +170

System.Web.HttpApplication.BeginProcessRequestNotification(HttpContext
context, AsyncCallback cb) +91

System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest
wr, HttpContext context) +508

Jordan.

Rob G

unread,
Jan 8, 2012, 10:59:01 AM1/8/12
to spar...@googlegroups.com
Hey Jordan,

I don't use the XML config often, I usually do it in code instead, but I think your xml should look something like this:

<spark>
   ....
   <views>
     <add name="Reporting"
          folderType="VirtualPathProvider"
          virtualBaseDir="~/Views/Reports"/>
   </views>
   ....
 </spark>

Hope that helps,
Rob

--
You received this message because you are subscribed to the Google Groups "Spark View Engine Dev" group.
To post to this group, send email to spar...@googlegroups.com.
To unsubscribe from this group, send email to spark-dev+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/spark-dev?hl=en.


Jordan

unread,
Jan 9, 2012, 9:01:14 AM1/9/12
to Spark View Engine Dev
Hi Rob,

Yes this works perfectly in every app I try it in apart from the one I
want to use it in. hmmm.

regards,
Jordan.
Reply all
Reply to author
Forward
0 new messages