2013-02-21 161 views
0

如何檢查在VS2010中調試時收到的所有Cookie?查看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的值。

+0

使用['GetCookies'](http://msdn.microsoft.com/en-us/library/system .net.cookiecontainer.getcookies.aspx)方法。 – Leri 2013-02-21 12:13:57

回答

0

使用這個 -

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

請檢查大/小寫如果沒有工作