How to stop Spark View Engine HTML encoding?
Asked Answered
S

1

8

Even with the following in spark section of web.config:

<pages automaticEncoding="false">

Things between ${...} Still get passed through H(...), which HTML encodes it.

How change this or should I just fall back to !{...}?

Selfregard answered 22/12, 2009 at 12:2 Comment(1)
automaticEncoding="false" helped to me. :/Dimorph
P
8

You can change Spark's default using its configuration, though I would recommend you use ${} when you want encoded HTML and !{} when you don't.

Spark can be configured from either Web.config or using a SparkSettings instance.


In Web.config, under your <spark> configuration, add:

<pages automaticEncoding="false">

You'll want to make sure you only have the one <pages/> element. I'm unsure if Spark's processor will raise an error if you have multiple.


Using SparkSettings, add:

SparkSettings settings = new SparkSettings()
    .SetAutomaticEncoding(false);

If you have these settings and still get automatic encoding, set a break-point at the point where you instantiate your SparkViewFactory (or use Console.WriteLine() or your logging framework) and have a look at:

mySparkViewFactory.Settings.AutomaticEncoding
Privacy answered 25/1, 2010 at 16:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.