There is a line, which is essentially a cookie. Interested in converting this string to cookies

Cookie recentlyVisitedAppHubs=233450%2C231430%2C48110%2C45760; Language=spanish; strInventoryLastContext=440_2; __utma=268881843.118202637.1372069740.1373472452.1373473085.10; __utmb=268881843.21.10.1373473085; __utmz=268881843.1373473085.10.4.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=(not%20provided); rgTopicView_General_4312225=%7B%22828934913396342649%22%3A%221373450285%22%2C%22846939615003500718%22%3A1373473557%7D; timezoneOffset=7200,0; sessionid=NDExNjE1NDE5; Login=765611979917322708A9C768; steamRememberLogin=76561197991732272; __utma=268881843.118202637.1372069740.1373472452.1373473085.10; __utmb=268881843.22.10.1373473085; __utmc=268881843; __utmz=268881843.1373473085.10.4.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=(not%20provided) 

///////////////////////

 CookieContainer cooks = new CookieContainer(); var str = "recentlyVisitedAppHubs=233450%2C231430%2C48110%2C45760; Language=spanish; strInventoryLastContext=440_2; __utma=268881843.118202637.1372069740.1373472452.1373473085.10; __utmb=268881843.21.10.1373473085; __utmz=268881843.1373473085.10.4.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=(not%20provided); rgTopicView_General_4312225=%7B%22828934913396342649%22%3A%221373450285%22%2C%22846939615003500718%22%3A1373473557%7D; timezoneOffset=7200,0; sessionid=NDExNjE1NDE5; Login=765611979917322708A9C768; steamRememberLogin=76561197991732272; __utma=268881843.118202637.1372069740.1373472452.1373473085.10; __utmb=268881843.22.10.1373473085; __utmc=268881843; __utmz=268881843.1373473085.10.4.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=(not%20provided)"; var rez = str.Split(';'); foreach (var item in rez) { var tmp = item.Split('='); Cookie cook = new Cookie(tmp[0],tmp[1]); cookieContainer.Add(cook); ; __utmc = CookieContainer cooks = new CookieContainer(); var str = "recentlyVisitedAppHubs=233450%2C231430%2C48110%2C45760; Language=spanish; strInventoryLastContext=440_2; __utma=268881843.118202637.1372069740.1373472452.1373473085.10; __utmb=268881843.21.10.1373473085; __utmz=268881843.1373473085.10.4.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=(not%20provided); rgTopicView_General_4312225=%7B%22828934913396342649%22%3A%221373450285%22%2C%22846939615003500718%22%3A1373473557%7D; timezoneOffset=7200,0; sessionid=NDExNjE1NDE5; Login=765611979917322708A9C768; steamRememberLogin=76561197991732272; __utma=268881843.118202637.1372069740.1373472452.1373473085.10; __utmb=268881843.22.10.1373473085; __utmc=268881843; __utmz=268881843.1373473085.10.4.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=(not%20provided)"; var rez = str.Split(';'); foreach (var item in rez) { var tmp = item.Split('='); Cookie cook = new Cookie(tmp[0],tmp[1]); cookieContainer.Add(cook); = (organic) | utmcmd = organic | utmctr = (not% CookieContainer cooks = new CookieContainer(); var str = "recentlyVisitedAppHubs=233450%2C231430%2C48110%2C45760; Language=spanish; strInventoryLastContext=440_2; __utma=268881843.118202637.1372069740.1373472452.1373473085.10; __utmb=268881843.21.10.1373473085; __utmz=268881843.1373473085.10.4.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=(not%20provided); rgTopicView_General_4312225=%7B%22828934913396342649%22%3A%221373450285%22%2C%22846939615003500718%22%3A1373473557%7D; timezoneOffset=7200,0; sessionid=NDExNjE1NDE5; Login=765611979917322708A9C768; steamRememberLogin=76561197991732272; __utma=268881843.118202637.1372069740.1373472452.1373473085.10; __utmb=268881843.22.10.1373473085; __utmc=268881843; __utmz=268881843.1373473085.10.4.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=(not%20provided)"; var rez = str.Split(';'); foreach (var item in rez) { var tmp = item.Split('='); Cookie cook = new Cookie(tmp[0],tmp[1]); cookieContainer.Add(cook); 

Displays error

 Дополнительные сведения: Параметр '{0}' не может быть пустой строкой. 

    1 answer 1

    If you look closely at the error message, there is an explanation:

     The parameter '{0}' cannot be an empty string. Parameter name: cookie.Domain 

    It is clear that you did not specify the domain to which the cookie belongs. It is specified either in the Cookie constructor, or by the argument of the Add command.

    Try, for example, like this:

     var domain = new Uri("http://www.google.com"); var rez = str.Split(';'); foreach (var item in rez) { var tmp = item.Split('='); Cookie cook = new Cookie(tmp[0], tmp[1]); cookieContainer.Add(domain, cook); }