Search code examples
c#asp.netrequest.querystring

Request.QueryString in asp.net


My code is work well but i want to send "Item" and "Mode" in encrypted form.any built in method in asp?if not plz suggest alternative solution.

string url = "QueryStringRecipient.aspx?";
url += "Item=" + lstItems.SelectedItem.Text + "&";
url += "Mode=" + chkDetails.Checked.ToString();
Response.Redirect(url);

Solution

  • Encrypted or encoded?

    To encode strings there is HttpServerUtility.UrlEncode

    public string UrlEncode(
        string s
    )
    

    Parameters

    s
        Type: System.String
        The text to URL-encode.
    

    Return Value

    Type: System.String
    The URL-encoded text.
    

    To decode HttpServerUtility.UrlDecode

    public static string UrlDecode(
        string str
    )
    

    Parameters

    str
        Type: System.String
        The string to decode.
    

    Return Value

    Type: System.String
    A decoded string.