C# How to get a QueryString value from the UrlReferrer

April 24, 2008
Categories: Web & Software Development
Tags:

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

  1. 4 Responses to “C# How to get a QueryString value from the UrlReferrer”

  2. By jimson on Jul 31, 2008

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

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

  3. By jimson on Jul 31, 2008

    how to get value of k in new.aspx

  4. By jill on Oct 24, 2008

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

  5. By Jeremy on Feb 23, 2009

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

    try:

    Page.Request…

Post a Comment