tks

博客园 首页 联系 订阅 管理
asp和asp.net之间的Session是不能共享的。
解决办法是:可以通过数据库,也可以通过WebService实现,不过这都很麻烦。

Cookie共享简单的多。
asp和asp.ne的Cookie只是存储的编码格式不同,经过简单转换就可以了。
如果使用asp保存COOKIES则中文将保存成某种格式比如,“中国”保存成了:“%D6%D0%B9%FA” 。
只需要在asp.net(c#)页面做处理。
代码如下:
//在ASP.Net中保存Cookie时:

        System.Text.Encoding theEncoding 
= System.Text.Encoding.GetEncoding("gb2312");
        
string cookieValue = HttpUtility.UrlEncode( "中国",theEncoding );

        Request.Cookies[
"SomeCookie"].Value = cookieValue;

//获取Cookie时:
        System.Text.Encoding theEncoding = System.Text.Encoding.GetEncoding("gb2312");
        
string cookieValue = Request.Cookies["SomeCookie"].Value;

        
string decodeValue = HttpUtility.UrlDecode(cookieValue, theEncoding);
posted on 2007-04-03 11:22  特困生  阅读(1495)  评论(2)    收藏  举报