I have a website that is still a mix of classic asp and asp.net (web forms). It's running on Windows Server 2008 R2, with IIS 7.5 and dot-net 4.0 Integrated Mode.
To set a particular cookie on the classic ASP side, I have something like the following:
Response.Cookies("CookieName") = "Test.02"
To set the same cookie on the dot-net side, I have the follwoing code:
Response.Cookies("CookieName").Value = "Test.02"
The strange thing that's happening is, for example, when I have a value for the cookie such as "Test.02". The dot-net code sets the value of the cookie (verified using Fiddler) to "Test.02". However, the classic asp sets the cookie value to "Test%2E02".
Anyone know why? AND, more importantly, how I can get the classic asp to write the cookie un-munged (url encoded)?
Interesting. Did some more google searching and it looks like classic asp always URLencodes the cookies (names AND values), where asp.net does not. Why did this change? I'm surprised we never really ran into this before... Seems strange that classic asp
CHANGES the value that I set and then does not change it back when I read it.
ojm37
Contributor
2248 Points
832 Posts
Interesting Cookies Issue
Mar 23, 2012 03:04 PM|LINK
I have a website that is still a mix of classic asp and asp.net (web forms). It's running on Windows Server 2008 R2, with IIS 7.5 and dot-net 4.0 Integrated Mode.
To set a particular cookie on the classic ASP side, I have something like the following:
Response.Cookies("CookieName") = "Test.02"To set the same cookie on the dot-net side, I have the follwoing code:
Response.Cookies("CookieName").Value = "Test.02"The strange thing that's happening is, for example, when I have a value for the cookie such as "Test.02". The dot-net code sets the value of the cookie (verified using Fiddler) to "Test.02". However, the classic asp sets the cookie value to "Test%2E02".
Anyone know why? AND, more importantly, how I can get the classic asp to write the cookie un-munged (url encoded)?
TIA,
ojm37
Contributor
2248 Points
832 Posts
Re: Interesting Cookies Issue
Mar 26, 2012 03:36 PM|LINK
Interesting. Did some more google searching and it looks like classic asp always URLencodes the cookies (names AND values), where asp.net does not. Why did this change? I'm surprised we never really ran into this before... Seems strange that classic asp CHANGES the value that I set and then does not change it back when I read it.
BrockAllen
All-Star
27438 Points
4893 Posts
MVP
Re: Interesting Cookies Issue
Mar 26, 2012 03:55 PM|LINK
Well, if you always decode it when you read it, then you'll be fine (although it feels like an extra step).
DevelopMentor | http://www.develop.com
thinktecture | http://www.thinktecture.com/
roopeshreddy
All-Star
20135 Points
3323 Posts
Re: Interesting Cookies Issue
Mar 29, 2012 05:15 PM|LINK
Hi,
Incase of Classic ASP, URL is encoded by default, where as in ASP.NET it allows the choice to user! If required he can encode!
Hope it helps u...
Roopesh Reddy C
Roopesh's Space