query string problem ?

Last post 06-18-2008 4:44 AM by harish448. 2 replies.

Sort Posts:

  • query string problem ?

    06-18-2008, 3:51 AM
    • Member
      80 point Member
    • harish448
    • Member since 02-14-2008, 4:38 AM
    • Bangalore,India
    • Posts 134

    hi all,

    i am using encryption and decryption for query string variable

    i am encrypting the url value before assign to url

    Response.Redirect("DownloadPrintFiles.aspx?url=" + Encrypt(e.CommandArgument.ToString(), true));

    encrypted url value is 6p39b2r4+L88jZwad7Wiu/O48DcV7s0dEcvTvXv97DKHu3/7Yn0DnnEuBP+KLLmsyoUEgjjPjnc=

    string folderToBrowse = Request.QueryString["url"] == null ? System.Configuration.ConfigurationManager.AppSettings["PrintedFilePath"] : Decrypt(Request.QueryString["url"], true);

    now i am retriving the url value from request.querystring["url"],true)

    i am getting output as  6p39b2r4 L88jZwad7Wiu/O48DcV7s0dEcvTvXv97DKHu3/7Yn0DnnEuBP KLLmsyoUEgjjPjnc=

     what i am observed is in when i am retriveing the url from http path its replacing the + symbol with space character

     can any help on this topic and what i have to do to avoid such problem please help me

    thanks in advance

     

  • Re: query string problem ?

    06-18-2008, 4:20 AM
    Answer
    • Star
      7,995 point Star
    • MelvynHarbour
    • Member since 06-06-2008, 9:33 AM
    • Cambridge, UK
    • Posts 1,288

    Your problem lies in understanding the different encodings that are being used. You encryption function is returning output that is Base64 encoded (http://en.wikipedia.org/wiki/Base64). Unfortunately, Base64 is not safe in a URL, as you have discovered. In particular, the '+' character is a special character in a URL, as indeed is the '=' character. You therefore need to URL encoded your encrypted string before you can use it as part of a URL. I suggest you use the Server.UrlEncode and Server.UrlDecode methods to make sure that the data can be passed through successfully:

    http://msdn.microsoft.com/en-us/library/zttxte6w.aspx

    http://msdn.microsoft.com/en-us/library/6196h3wt.aspx

     

  • Re: query string problem ?

    06-18-2008, 4:44 AM
    • Member
      80 point Member
    • harish448
    • Member since 02-14-2008, 4:38 AM
    • Bangalore,India
    • Posts 134

    thanks alot

Page 1 of 1 (3 items)