开发者

How to stop Spark View Engine HTML encoding?

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

<pages automatic开发者_开发百科Encoding="false">

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

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


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
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜