【发布时间】:2011-06-28 06:43:36
【问题描述】:
我需要将 cookie 值传递给另一个具有相同域的 Url。我有两个具有相同域名的 url。一个用于身份验证的 Url 另一个用于检索数据。我首先执行了经过身份验证的 url。使用此身份验证 cookie,我想执行第二个 url ..
如何做到这一点...我无法将 cookie 添加到 socond url
这是我的代码..
字符串 url = "http://172.16.xx.xxx:8080/cms?login&username=santhu&password=welcome"; 字符串 url1 = "http://172.16.xx.xxx:8080//cms?status=ProcessStatus"; 字符串结果 = null;
try
{
WebClient client = new WebClient();
WebClient client1 = new WebClient();
result = client.DownloadString(url);
TextBox1.Text = result.ToString();
if (Response.Cookies["JSESSIONID"] != null)
TextBox1.Text = Server.HtmlEncode(Response.Cookies["JSESSIONID"].Value);
client1.Headers.Add("JSESSIONID", TextBox1.Text);
result = client1.DownloadString(url1);
TextBox2.Text = result.ToString();
}
catch (Exception ex)
{
}
【问题讨论】: