I need to store messages in different languages in Http Header:
Response Headers
Cache-Control private
Content-Type text/html; charset=utf-8
Server Microsoft-IIS/7.5
X-AspNetMvc-Version 3.0
X-Message-Type Success
X-Message <p>Token wysÅany</p>
X-AspNet-Version 4.0.30319
X-Powered-By ASP.NET
Date Wed, 18 May 2011 12:49:26 GMT
Content-Length 2
But, as you can see X-Message looses it’s formatting. it should be “Token wysłany”.
Help. thanks
EDIT:
this is what i have:
if (filterContext.HttpContext.Request.IsAjaxRequest())
{
var viewData = filterContext.Controller.ViewData;
var response = filterContext.HttpContext.Response;
foreach (var messageType in Enum.GetNames(typeof(MessageType)))
{
var message = viewData.ContainsKey(messageType)
? (ErrorMessageExtensions.ErrorMessage)viewData[messageType]
: null;
if (message != null) // We store only one message in the http header. First message that comes wins.
{
response.AddHeader("X-Message-Type", messageType);
response.AddHeader("X-Message", message.RenderAjax());
return;
}
}
}
i’m trying to integrate messaging into my mvc app (like so): http://blogs.taiga.nl/martijn/2011/05/03/keep-your-users-informed-with-asp-net-mvc/ the only problem is that it needs to support multilanguages. What are some other options (or fixes for this solutions that would support other language characters)? thanks
I was having the same problem with this very messaging project by Martijn Boland. In my case I needed accented characters that we use in the Brazilian Portuguese language as: é á í ó ã õ, etc…
I did this to solve the problem:
and then in the view page (.cshtml) where you show the message:
See that I changed from
$("#messagewrapper .messagebox").text(message);to
$("#messagewrapper .messagebox").html(message);That’s because now we’re getting entity numbers (
HTMLmarkup ) instead of plain text.Doing so you won’t need that additional decode-jquery-plugin you mention in your answer.