ASP vs. ASP.NET: Escapable chars in cookie name?

S

SL

Hi all...

I am currently porting an application from ASP to ASP.NET.

I seem to be experiencing different behavior when issuing cookies in
ASP.NET vs. what I experienced in ASP.

The name of my cookie contains underscore characters ("_"). In
theory, if I use my original ASP application to set the cookie, and
then use the ASP.NET application to set the cookie, the ASP.NET
application should be overwriting the cookie set by the ASP
application (i.e. I should end up with only one cookie). Instead, I
end up with two seperate cookies.

When I view the browser cookies by issuing the URL
"javascript:alert(document.cookie)" to the browser, for some reason
the underscores in the name of the cookie created in ASP show up as
escaped characters, i.e. as %5F, whereas the underscores in the name
of the cookie created with ASP.NET actually show up as underscores.
For example, "%5FMY%5FCOOKIE%5F" vs. "_MY_COOKIE_".

Does anyone know what might be causing this discrepency and how I can
make ASP.NET behave as ASP did in this regard?

Here is my ASP code...

CookieName = "_MY_COOKIE_"
Response.Cookies(CookieName).Domain = strDomainName
Response.Cookies(CookieName).Path = "/"
Response.Cookies(CookieName).Secure = True
Response.Cookies(CookieName) = strCookiePayload

Here is my ASP.NET code (using C#)

cookieName = "_MY_COOKIE_";
Response.Cookies[cookieName].Domain = strDomainName;
Response.Cookies[cookieName].Path = "/";
Response.Cookies[cookieName].Secure = true;
Response.Cookies[cookieName].Value = strCookiePayload;

Any help would be greatly appreciated. Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Cookie with double name 1
Cookie problem 8
double cookie 2
Cookie Problems 1
ASP.Net cookie -> ASP -> ASP.Net 3
Unable to retrieve cookie set via javascript 2
cookie trouble 3
Cookie Basics 1

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top