Encoded Cookies Error
My application is separated in 3 different layers. WEB, BLL and DAL. I set a cookie from web layer and then I requested it from another page to display it to the user.
HttpContext.Current.Response.Cookies["FlashMessenger"]["Type"] = "error";
HttpContext.Current.Response.Cookies["FlashMessenger"]["Message"] = "Aucun vol trouvé pour la date donnée. S'il vous plaît affiner votre recherche.";
when I am doing the same from BLL and trying to display it, the returned message is broken.
var flashMessengerC = Request.Cookies["FlashMessenger"];
var message = flashMessengerC["Message"];
var type = flashMessengerC["Type"];
MsgLBL.Text = message;
This is what I received "Aucun vol trouvé pour la date donnée. S'il vous plaît affiner votre recherche."
I tried to Html encod开发者_开发百科ed and afterwards decoded but it does the same. I had a look on browsers cookies and there was in correct format.
What could cause this?
I will appreciate any comment.
Thanks
Couldn't be 100% sure, but sounds like your BLL is running a different thread culture to your UI. Having your BLL requesting cookies isn't a great design anyway - better to have the information they actually need passed into them, rather than tying it to a particular implementation, e.g.:
class FlashMessengerInfo
{
public string Message { get; set; }
public string Type { get; set; }
}
class MyBLL
{
public MyBLL(FlashMessengerInfo messageInfo)
{
}
}
from the web ui, you'd populate this object and pass it on through to your BLL, leaving it uncoupled from the HttpRequest object.
精彩评论