BUG: System.Net.CookieContainer AddCookies method

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Source:

string cookie = @"MyCookie=MyValue; domain=msdn.microsoft.com; path=/";
CookieContainer cc = new CookieContainer();
cc.SetCookies(new Uri("http://msdn.microsoft.com"), cookie);

Error:

System.Net.CookieException: An error has occurred when parsing Cookie header
for Uri 'http://msdn.microsoft.com/'. ---> System.Net.CookieException: The
'Domain'='msdn.microsoft.com' part of the Cookie is invalid.
at System.Net.Cookie.VerifySetDefaults(CookieVariant variant, Uri uri,
Boolean isLocalDomain, String localDomain, Boolean set_default, Boolean
isThrow)
at System.Net.CookieContainer.CookieCutter(Uri uri, String HeaderName,
String setCookieHeader, Boolean isThrow)
--- End of inner exception stack trace ---
at System.Net.CookieContainer.CookieCutter(Uri uri, String HeaderName,
String setCookieHeader, Boolean isThrow)
at System.Net.CookieContainer.SetCookies(Uri uri, String cookieHeader)
at ConsoleApplication1.Class1.Main(String[] args) in
c:\source\consoleapplication1\consoleapplication1\class1.cs:line 17
 
Back
Top