Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / April 2008

Tip: Looking for answers? Try searching our database.

.NET Cookie Parsing

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mike C# - 16 Apr 2008 02:12 GMT
Is there a decent cookie parser out there somewhere?  I keep running into
cookies that .NET can't handle.  I've also found a couple of other parsers
but they're choking as well.
Mike C# - 16 Apr 2008 04:37 GMT
As I dig a little deeper into it, it appears that .NET is parsing the
Set-Cookie header properly. The cookies are even split up properly in the
private members deep down.  But somehow they're getting *mangled* on their
way back up when you try to actually access them.  This doesn't make a lot
of sense to me.  Anyone had any experience with this?  Hints, tips?  Thanks.

> Is there a decent cookie parser out there somewhere?  I keep running into
> cookies that .NET can't handle.  I've also found a couple of other parsers
> but they're choking as well.
Patrice - 19 Apr 2008 13:17 GMT
Do you have a bare bone repro for this ?

I had this once in classic ASP if you put characters that are themselves
used to separate cookies one from the other or to separate the cookie name
and value. Encoding those values should fix the problem.

--
Patrice

> As I dig a little deeper into it, it appears that .NET is parsing the
> Set-Cookie header properly. The cookies are even split up properly in the
[quoted text clipped - 6 lines]
>> cookies that .NET can't handle.  I've also found a couple of other
>> parsers but they're choking as well.
Mike C# - 19 Apr 2008 23:39 GMT
I did some investigation, it turns out that the CookieCollection uses a
too-simple string split function instead of actually attempting to "parse"
the cookie.  So any cookies that contain commas get mangled.  I then tried
to grab the data from the Set-Cookie header, but those values get mangled in
a similar fashion.  What's really annoying is that I can see the properly
parsed values in Visual Studio, way down in the private members of the
headers collection, but they're not exposed anywhere except in the Visual
Studio watch window.  I ended up creating my own better parser to handle it.
The website I was playing around with was Expedia.com, BTW.  I imagine there
are probably a lot of other websites that use commas in cookies - they
should fix the handling behaviour in .NET.

> Do you have a bare bone repro for this ?
>
[quoted text clipped - 15 lines]
>>> into cookies that .NET can't handle.  I've also found a couple of other
>>> parsers but they're choking as well.
Bill Woodruff - 20 Apr 2008 03:59 GMT
Mike C# wrote :

"I ended up creating my own better parser to handle it."

Hi Mike,

I imagine there are many people, besides myself, who would really appreciate
a brief tutorial and your solution if you have the time, inclination, and
freedom from contractual constraint, that would allow you to post an article
on CodeProject or a similar venue, or share code.

thanks, Bill
Mike C# - 24 Apr 2008 01:00 GMT
> Mike C# wrote :
>
[quoted text clipped - 8 lines]
> article
> on CodeProject or a similar venue, or share code.

This particular piece of code was part of a work for hire, so I can't post
it without permission.  I'll discuss with the person I'm writing it for and
see if they're willing to allow it.  If not, I may write another version of
the solution (time permitting) and post that.  I really believe the absolute
best solution would be for the .NET team to fix the problem in the
Framework, but until then I guess we just have to make do with custom
parsing solutions :(

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.