C# How to get a QueryString value from the UrlReferrer

To get a QueryString value from the previous pages URL (aka: the UrlReferrer) you can use HttpUtility.ParseQueryString.

Like this!

NameValueCollection nameValueCollection = HttpUtility.ParseQueryString(Request.UrlReferrer.Query);
string keyword = nameValueCollection["kw"];

“And that’s all I have to say about that.”

This entry was posted in Web & Software Development and tagged , . Bookmark the permalink.

4 Responses to C# How to get a QueryString value from the UrlReferrer

  1. jimson says:

    int k=9;
    Response.Redirect(“new.aspx?k”,true);

    nxt page ie:new.aspx
    string str=Request.QueryString[“k”]

  2. jimson says:

    how to get value of k in new.aspx

  3. jill says:

    I have tried this but my Request.UrlReferrer.Query is empty. Do you know any reason why the parameters are not being sent through

  4. Jeremy says:

    Request.UrlReferrer.Query is empty. Do you know any reason why the parameters are not being sent through

    try:

    Page.Request…

Leave a Reply

Your email address will not be published. Required fields are marked *