Tridon UI 2012 Session Preview Web Service using incorrect encoding

16

I am using Tridion UI 2012 on our website (which is built using DD4T). The problem we're facing is that the session preview web service does successfully commit the edited content to the session-preview database, but it loses its UTF-8 encoding. So everything is stored with symbols like "Â" etc. The encoding is however maintained in the broker database. It's just the session preview database which contains non-UTF8 text.

I have updated the web.config for the session preview web service with the following but this doesn't have an effect:

<globalization culture="auto" fileEncoding="utf-8" uiCulture="auto" requestEncoding="utf-8" responseEncoding="utf-8" responseHeaderEncoding="utf-8" />

Any ideas?

NOTE: This problem only started appearing after we included the following new entry in the same web.config (i.e. session preview web service):

<httpRuntime maxRequestLength="2097151" />

Thanks.

Qas

Posted 2013-03-12T16:52:54.533

Reputation: 343

Answers

20

Session preview bypasses the standard publishing mechanism. I found it the hard way too, that after "previewing" content my characters were wrong.

Easily fixed if you know what to search for.

The problem is that you need to tell the Java process on the delivery side to use UTF-8 encoding, which is usually handled nicely by the Deployer... but with Session preview you don't have a deployer.

Add the following to the registry of the machine where the WebService is running:

  • Create a registry key called HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Tridion\Content Delivery\General (create all keys you need to get this far)
  • Add a string value with name jvmarg1 and value -Dfile.encoding=UTF-8

Restart the webservice, try again.

EDIT I don't know for sure if this is required on the webservice machine or the Staging website machine... now that I think of it, it should be on the staging machine. I always had both running on the same server, so I don't know which one needed it.

Nuno Linhares

Posted 2013-03-12T16:52:54.533

Reputation: 27 884

I've just seen these symptoms and fixed the problem by applying the registry setting to the server running the PREVIEW WEBSERVICE. – Dominic Cronin – 2014-12-18T08:28:17.920

This worked on another "all-in-one" machine for me, but the last key, which was already there, was Content Delivery with a space. I then created General inside of it with the String Value inside of that. – Alvin Reyes – 2013-07-19T22:04:10.680

I'm having the exact same problem, but on a JAVA implementation. Session Preview however is on a .NET IIS Web App. Is this still the right answer for this? – MDa – 2013-03-12T20:48:26.077

2This is the right answer as long as you set it to where the staging application with session preview enabled is running. It does not matter for the preview web service (at least I don't think it does). For a Java staging app, you need to set the encoding at the application server level (JVM startup parameter). This worked for me in Java. I assume you could also use page directives in the page template as well. But UTF-8 usually takes care of any special characters, so probably no harm in setting this at the app server level. – Amit Mehta – 2013-03-12T20:57:10.373

3If you're running a Java web app you can probably set this -Dfile.encoding=UTF-8 as part of your JVM parameters. It will also work with the registry entry (if you're on windows obviously) and for .NET there's no other way to specify it. – Nuno Linhares – 2013-03-12T21:22:21.973

1

+1 for Nuno's answer. This (also) worked for me: http://stackoverflow.com/a/623036/1221887

– Albert Romkes – 2013-03-13T07:05:38.167

Thanks very much Nuno! it's solved our problem and we finally have UI2012 working! :) – Qas – 2013-03-13T10:10:19.833

1I've just followed this post - for some reason setting the registry key did not work for me (I set it on the Staging machine and the Session Preview web service machine) However I followed Albert's link in the comment above and that seemed to fix it. Thought i'd leave a comment incase anyone else is struggling with the same thing! – Dave Houlker – 2013-04-02T20:06:33.603

7

It is tricky to diagnose, but I noticed that I don't have the 'culture' and 'uiCulture' attributes in my Session Preview web service's web.config:

<globalization fileEncoding="UTF-8" requestEncoding="UTF-8" responseEncoding="UTF-8"/>

I suspect that this may be forcing the webservice to use the culture that the Session Preview Extension uses.

Also, I assume that your Content Delivery web service is running on IIS v7.5? If so, then the 'maxAllowedContentLength' attribute is now used to specify the maximum file upload size (rather than the 'maxRequestLength'). Please see the ASP.NET blog for more details.

Hope it helps.

Jonathan Williams

Posted 2013-03-12T16:52:54.533

Reputation: 12 464