1.asp文件:
---------------------------------------------
<%
response.cookies("user_name")="1"
response.write request.cookies("user_name")
response.redirect "1.aspx"
%>
----------------------------------------------
1.aspx文件:
----------------------------------------------
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><script runat="server">
void Page_Load(object sender, EventArgs e)
{
HttpCookie strcookie =new HttpCookie("user_name");
Response.Write(strcookie.Value);
}
</script><html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body></body>
</html>
前一个是asp文件,后一个是asp.net文件
---------------------------------------------
<%
response.cookies("user_name")="1"
response.write request.cookies("user_name")
response.redirect "1.aspx"
%>
----------------------------------------------
1.aspx文件:
----------------------------------------------
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><script runat="server">
void Page_Load(object sender, EventArgs e)
{
HttpCookie strcookie =new HttpCookie("user_name");
Response.Write(strcookie.Value);
}
</script><html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body></body>
</html>
前一个是asp文件,后一个是asp.net文件
Response.Write(strcookie.Value);这里不对用NEW,你ASP文已经产生了,为什么还要NEW
再说,你的ASP文件并没有设置COOKIE的生存时间!
HttpCookie _strcookie = Request.Cookies["username"];
Label1.Text = _strcookie.Values[4];结果显示如下:
%C0%EE%D0%A1%C1%FA 这是为什么呀?
我要是把cookie里的值付于数字或英文字母,用Label1.Text =_strcookie.Values[4];就可以正常显示,但用储存汉字,显示的就是乱码!
我是用asp写的cookie,用asp.net显示的!
为什么会这样?
已经求了两天了,拜托大家给我指个路,让我能在asp和asp.net两个网页里相互传递数据!谢谢!