查看Cookie容器包含的内容?

时间:2013-02-21 11:53:16

标签: c#

如何在VS2010中调试时检查所有cookie的接收情况?

                CookieContainer cookiejar = new CookieContainer();
                webRequest.Method = "POST";
                webRequest.Host = "www.site.com";
                webRequest.ContentType = "application/x-www-form-urlencoded";
                webRequest.UserAgent = "~~~~";
                webRequest.Accept ="~~~~";
                webRequest.Referer = "http://www.site.com";
                webRequest.CookieContainer = cookiejar;  
                HttpWebResponse webresponse =  (HttpWebResponse)webRequest.GetResponse();

cookiejar <=显示了6个Cookie的数量。但我在其中找不到任何Cookie值。

1 个答案:

答案 0 :(得分:0)

使用此 -

if(Request.Cookies["key"]!=null)
{
   var value=Request.Cookies["key"].Value;
}

如果不能正常工作,请检查大/小写