locked
Cookie Encoding RRS feed

  • Question

  • User-66812352 posted
    Question! Good one! 1) I have aa cookie set in asp. Request("UI")("id") = "España123" 2) And then redirects to myuid.aspx. In this page, I do Request.Cookies("UI").Values.Get("id"). The value comes back as "Espa%F1a123". HOW DO I CONVERT IT BACK TO "España123". I TRIED SERVER.URLDECODE(). IT CHANGES TO "Espaa123"( SEE WHAT I'M SAYING, I LOOSE THE "ñ") THE "%F1" IS THE HEX VALUE OF "ñ". BUT HOW DO I GET THAT BACK FROM THE COOKIE? ANY HELP IS GREATLY APPRECIATED. ALSO THE BIG QUESTION I HAVE IS WHAT IS ASP.NET DOING WHEN CHANGING THE VALUE TO HEX.... AND HOW CAN WE REVERT IT?
    Thursday, April 8, 2004 2:36 PM

Answers

  • User113421904 posted
    Hi, Try Server.HtmlDecode your cookie.
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, March 19, 2007 3:17 AM
  • User253167664 posted

    I don't see any problem, or I am not understanding your question.

    Lets's see you have:

    Default.aspx where we create the coockie and make the redirection to myuid.aspx

    HttpCookie cookie = new HttpCookie("UID");

    cookie["id"] = "España123" ;

    Response.Cookies.Add(cookie);

    Response.Redirect("myuid.aspx");

    Next we have myuid.aspx with smth like this:

    protected void Page_Load(object sender, EventArgs e)

    {

    Response.Write(Request.Cookies["UID"]["id"]);

    }

    all went fine!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, March 22, 2007 3:36 AM

All replies

  • User-201858242 posted

    In The Name of God

    Hi 

    I got the same issue here. nobody knows the solution?

     thanks

    Friday, March 16, 2007 2:42 AM
  • User113421904 posted
    Hi, Try Server.HtmlDecode your cookie.
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, March 19, 2007 3:17 AM
  • User-201858242 posted

    In The Name if God

    hi

    It did not work. i used the simplest form of Server.HtmlDecode(string s).

    maybe i am using it in a matter that you did not mean. can you bring me an example of how to use it. 

    thanks 

    Tuesday, March 20, 2007 2:38 AM
  • User253167664 posted

    I don't see any problem, or I am not understanding your question.

    Lets's see you have:

    Default.aspx where we create the coockie and make the redirection to myuid.aspx

    HttpCookie cookie = new HttpCookie("UID");

    cookie["id"] = "España123" ;

    Response.Cookies.Add(cookie);

    Response.Redirect("myuid.aspx");

    Next we have myuid.aspx with smth like this:

    protected void Page_Load(object sender, EventArgs e)

    {

    Response.Write(Request.Cookies["UID"]["id"]);

    }

    all went fine!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, March 22, 2007 3:36 AM