Thursday, December 23, 2010

Cookie transition between classic ASP and ASP.NET

Guys, here is what i have came across recently.

I have a classic asp application that has a login module. There is another sub folder that has dotnet pages (.aspx). Any user who logs in to the asp application should be automatically able to view the .net pages too. But the aspx page was not able to access the cookie created in asp page. After a reasearch for some time i found out the reason why it was hapening like that.

Here is the reason:
My cookie name in the application is "cki_user". Point to be observed is the underscore symbol in the name. In classic ASP, the cookie name will be url encoded and created. That means, the actual cookie name will be "cki%5Fuser". But in asp.net, there will no url encoding hence the name remains "cki_user" when requesting. Hence i was not able to access the value. Finally i had to access it using Request.Cookies["cki%5Fuser"] which worked well.

No comments: