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.”

4 thoughts on “C# How to get a QueryString value from the UrlReferrer

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

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

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

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

    try:

    Page.Request…

Leave a Reply to jill Cancel reply

Your email address will not be published.