c# - HttpClient Not Saving Cookies -


i using new httpclient handle project's web surfing needs; however, although correctly set, httpclient not save cookies cookie container , empty.

code

private cookiecontainer _cookiecontainer = new cookiecontainer(); private httpclient httpclient { get; set; } private httpclienthandler httpclienthandler { get; set; }  public initialize() {     httpclienthandler = new httpclienthandler                             {                                 allowautoredirect = true,                                 usecookies = true,                                 cookiecontainer = _cookiecontainer                             };     httpclient = new httpclient(httpclienthandler); }  public cookiecontainer cookies {     { return _cookiecontainer; }     set { _cookiecontainer = value; } }  public void test() {     //this empty, although sure site saving login cookies     var cookies = cookies; } 

weird... did tried directly use httpclienthandler's cookiecontainer ?

code :

public initialize() {     httpclienthandler = new httpclienthandler                             {                                 allowautoredirect = true,                                 usecookies = true,                                 cookiecontainer = new cookiecontainer()                             };     httpclient = new httpclient(httpclienthandler); }  public cookiecontainer cookies {     { return httpclienthandler.cookiecontainer; }     set { httpclienthandler.cookiecontainer = value; } } 

Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

php - joomla get content in onBeforeCompileHead function -