All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
HTML 初学者指南(4)_[Html教程]
PHP脚本的8个技巧(1)把PHP安装为Apache DSO_[PHP教程]
新标准的熟悉和入门_[Html教程]
春节大盘点:.NET技术的回顾与展望_.net资料_编程技术
Linux,下用PHP4连接,Oracle8i,的方法_php资料_编程技术
在PHP中全面阻止SQL注入式攻击之一_[PHP教程]
批量修改同一个目录中的所有文本文件的方法_[SQL,Server教程]
asp.net2.0中使用session进行用户登录验证
C#中实现VB中的CreateObject方法_.net资料_编程技术
加密和解密ASP.NET配置文件(Web.config)_[Asp.Net教程]
Reading number is top 10 pictures
Breasts woman big set 2
囚犯暴乱了咋办?
Look for from human art net, is good--2
含苞欲放的素颜美少女1
So beauty, will let you spray blood4
修电脑也有这么漂亮的美女
Photographed the passion of the clients and prostitutes in the sex trade picture2
Steal to eat bacon bird
八个盛产美女的国家2
Fury xp desktop theme
Download software ranking
美女写真2
Boxer vs Yellow4
在线棋牌游戏3.05版
Boxer Classic video3
功夫熊猫2(上集)
Boxer's Top ten classic battle2
Rio big adventure
The king of fighters 97(Mobile phone games-apk)
White deer villiage
dreamweaver8中文版
aaa published in(发表于) 2013/12/6 10:25:33 Edit(编辑)
Asp.net的HttpCookie写入汉字读取时为乱码的解决方法_.net资料_编程技术

Asp.net的HttpCookie写入汉字读取时为乱码的解决方法_.net资料_编程技术

Asp.net的HttpCookie写入汉字读取时为乱码的解决方法_.net资料_编程技术-数科优化网

今天有个学生妹妹问我:在Asp.net的HttpCookie中写入汉字,读取值为什么全是乱码?其实这是因为文字编码而造成的,汉字是两个编码,所以才会搞出这么个乱码出来!其实解决的方法很简单:只要在写入Cookie时,先将其用Url编码,然后再写入,当我们读取时再解码就OK了,希望更多的学生妹妹能解决它,呵呵!


例子:


Cookie的写入:


1HttpCookie cookie=new HttpCookie("Simple");
2cookie.Values.Add("Simple1",HttpUtility.UrlEncode("大叔,你好!"));
3cookie.Values.Add("Simple2","English is OK!Nothing we should do!");
4Response.AppendCookie(cookie); Cookie的读取:
1HttpCookie cookie=Request.Cookies["Simple"];
2string simple1=HttpUtility.UrlDecode(cookie["Simple1"]);
3string simple2=cookie["Simple2"]; 这样simple1="大叔,你好!";simple2="English is OK!Nothing we should do!";


很简单吧!!!






添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.