ASP and Asp.net share cookies

Source: Internet
Author: User
The cookie directly written by ASP cannot be directly read by Asp.net. To rewrite it, ASP CodeAs follows:
Response. Cookies ("adminname") = RS ("username ")
Response. Write Request. Cookies ("adminname ")

The second line seems to be somewhat redundant, and the code is somewhat strange. However, in this case, Asp.net can indeed read it correctly. The code in Asp.net is as follows:
Adminname = request. Cookies ["adminname"]. value. tostring ();

Since the value I uploaded may be Chinese, I tried Chinese. As a result, Asp.net reads yes.
% D5 % Fe % D6 % Ce % B4 % A6

This is also very simple, just turn it around, and the result can't be converted with server. urldecode, think of the previous section of Baidu thievesProgramA code conversion method is as follows:
System. Web. httputility. urldecode (adminname, system. Text. encoding. getencoding (936 ));
In this way, you can obtain normal Chinese characters;

I will sort out the above ideas;
To write a cookie in ASP, follow these steps:
Response. Cookies ("Cookie name") = "cookie value"
Response. Write Request. Cookies ("Cookie name ")

When reading data in Asp.net, including reading Chinese:
String cookie;
Cookie = request. Cookies ["Cookie name"]. value. tostring ();
Cookie = system. Web. httputility. urldecode (cookie, system. Text. encoding. getencoding (936 ));

I only write ASP to write cookies here. The Asp.net reading method does not write Asp.net to write cookies and can be read using ASP. I have the opportunity to study it again.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.