Change DefaultPageEncoding

This is a place to discuss how to adapt mojoPortal to the needs of different cultures. Before asking questions here please first review the localization documentation.

This thread is closed to new posts. You must sign in to post in the forums.
12/17/2009 9:13:51 PM
Gravatar
Total Posts 10

Change DefaultPageEncoding

Joe, I changed the DefaultPageEnconding from "utf-8" to "iso-8859-1" for the site but when view the source code it still show utf-8. In fact I could not find a way to do it via Mojo Admin so that is why I edited the value in mp_sites directly. I touched web.config but still shows utf-8.

Am I missing something?

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>

thanks

Rod

12/18/2009 5:20:27 AM
Gravatar
Total Posts 18439

Re: Change DefaultPageEncoding

Hi Rod,

In newer versions this is controlled by Web.config/user.config settings:

<!--

Set AutoSetContentType to false if you would rather add the meta ContentType yourself in layout.master file of your skin

if true the MetaContentControl will render it according to the ContentMimeType and ContentEncoding settings

Changed the default from application/xhtml+xml to text/html as of mojoportal version 2.3.1.3 Html 5 now seems the future rather than Xhtml

-->

<add key="AutoSetContentType" value="true" />

<add key="ContentMimeType" value="text/html" />

<add key="ContentEncoding" value="utf-8" />

Hope it helps,

Joe

12/18/2009 6:49:10 AM
Gravatar
Total Posts 10

Re: Change DefaultPageEncoding

Thanks. My Mojo version is 2-3-0-8 and the keys you suggested are not recognized for this version. I guess I need to upgrade right?
I am having google search indexing problems with with utf-8 for special latin characters and I need to have this charset changed urgently.

For now this is my solution until I upgrade.

Added this code to default.aspx.cs

protected override void Render(System.Web.UI.HtmlTextWriter writer)

{

StringWriter sw = new StringWriter();

HtmlTextWriter htmltw = new HtmlTextWriter(sw);

base.Render(htmltw);

string output = sw.ToString();

if (output.IndexOf("charset=utf-8") > 0)

{

output = output.Replace("charset=utf-8", "charset=iso-8859-1");

}

if (output.IndexOf("application/xhtml+xml;") > 0)

{

output = output.Replace("application/xhtml+xml;", "text/html;");

}

writer.Write(output);

}

PS: I am aware that this is not the best approach because it can degrade performance.

 

Rod

You must sign in to post in the forums. This thread is closed to new posts.