tag:blogger.com,1999:blog-743186551507405974.post1061698187656980966..comments2023-11-05T15:49:23.882+08:00Comments on .NET Expertise: CookieContainer domain handling bug fixLaNNhttp://www.blogger.com/profile/05893225301825179972noreply@blogger.comBlogger5125tag:blogger.com,1999:blog-743186551507405974.post-6295803810850907372020-03-28T19:44:35.204+08:002020-03-28T19:44:35.204+08:00thanks for sharing dude it really help me to under...thanks for sharing dude it really help me to understand thank you.<br /><a href="https://www.oixapey.com/dp-full-form" rel="nofollow">dp full form </a><br /><a href="https://www.oixapey.com/website-kaise-banaye" rel="nofollow"> free me website banaye</a><br /><a href="https://www.oixapey.com/phd-kaise-kare" rel="nofollow"> phd </a><br /><a href="https://www.oixapey.com/polytechnic-kya-hai-kaise-kare-hindi" rel="nofollow">polytechnic kaise kare </a><br /><a href="https://www.oixapey.com/ip-full-form" rel="nofollow">ip full form </a><br /><a href="https://www.oixapey.com/gmail/mobile/email-id-kaise-banaye" rel="nofollow"> email id banaye</a><br /><a href="https://www.bloggerride.com/download-Pubg-host/strange-vpn-apk" rel="nofollow"> strange vpn</a><br /><a href="https://www.bloggerride.com/anti-ban-host" rel="nofollow"> anti ban host download</a><br /><a href="https://www.bloggerride.com/pubg-mobile/vip-script-download" rel="nofollow"> vip script download</a><br /><a href="https://www.bloggerride.com/host-file/anti-download-pubg-mobile" rel="nofollow"> anti ban vip</a><br />Frgenerique Teamhttps://www.blogger.com/profile/04425079686418349275noreply@blogger.comtag:blogger.com,1999:blog-743186551507405974.post-32065288238421892862013-07-08T23:57:24.812+08:002013-07-08T23:57:24.812+08:00//bug fix, exists only in 3.5 FW, please wrap it w...//bug fix, exists only in 3.5 FW, please wrap it with defines<br /> //http://dot-net-expertise.blogspot.com/2009/10/cookiecontainer-domain-handling-bug-fix.html<br /> if(!value.Contains("://www.")) //we are going to hit the bug<br /> {<br /> string urlWWW = value.Replace("://", "://www.");<br /> Uri uriWWW = new Uri(urlWWW);<br /> foreach (Cookie c in _cookieContainer.GetCookies(uriWWW))<br /> if (c.Domain.StartsWith("."))<br /> request.Headers["Cookies"] += c.Name + "=" + c.Value + ";"; //manually add the cookies<br /> }<br /> //~bug fix<br />Dmitry Klymenkohttps://www.blogger.com/profile/06058280758384756839noreply@blogger.comtag:blogger.com,1999:blog-743186551507405974.post-52463217985681105822010-12-07T10:34:38.911+08:002010-12-07T10:34:38.911+08:00Hi,
Fix doesn't work right for me.
I'm do...Hi,<br /><br />Fix doesn't work right for me.<br />I'm doing some requests on a domain and get cookies back for domain starting with ".", then I add my own for that domain (without www) and they end up in the collection as domain without ".".<br />When I call you fixing code afterwards, the cookies I just added get overwritten by the ones that were there before.<br /><br />Ideas?Claudiushttps://www.blogger.com/profile/14418261009362397955noreply@blogger.comtag:blogger.com,1999:blog-743186551507405974.post-22729887251569225942009-10-21T01:47:04.440+08:002009-10-21T01:47:04.440+08:00This may sound obvious, but this also applies to u...This may sound obvious, but this also applies to using the CookieContainer in HttpWebRequest and WebClient.<br />It's really a pain in the butt, especially since Microsoft decided to fix this so late. So, thank you VERY much for the fix! I've applied it by executing BugFix_CookieDomain after every SetCookies-call.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-743186551507405974.post-76294396324302755592009-10-09T22:50:36.313+08:002009-10-09T22:50:36.313+08:00Thanks,
someone has posted a workaround in the mi...Thanks, <br />someone has posted a workaround in the microsoft bug report page:<br /><br />I've written a small function to work around the problem,<br />it adds the "www." to each Uri which seems to "solve" the problem:<br /><br />public static Uri FixUriForCookies(string Url)<br />{<br />Uri Uri = new Uri(Url);<br /><br />if (!Uri.Host.StartsWith("www"))<br />{<br /> if (Uri.Scheme == "http")<br /> {<br /> Uri = new Uri(Url.Replace("http://", "http://www."));<br /> }<br /> else if (Uri.Scheme == "https")<br /> {<br /> Uri = new Uri(Url.Replace("https://", "https://www."));<br /> }<br />}<br />return Uri;<br />}<br /><br />didn't test myself but I don't it works for all urls such as sub-domains!Salarhttps://www.blogger.com/profile/00714100498487650595noreply@blogger.com