Get URL from Query Parameter

SAMPLE DATA URL

_http://abc.com/cache.ashx?feedURL=http://search.twitter.com/search.rss?q=from%3AAbbottNews&rpp=3&clientsource=TWITTERINC_WIDGET&include_entities=true&result_type=recent&1334673762143=cachebust

I'm try to get value of query parameter FeedURL and below what I get;

Actual: http://search.twitter.com/search.rss?q=from%3AAbbottNews&rpp=3&clientsource=TWITTERINC_WIDGET&include_entities=true&result_type=recent&1334673762143=cachebust

What I'm getting: http://search.twitter.com/search.rss?q=from%3AAbbottNews

Required : I need the complete URL.

Note: It truncates from second parameter onwards

Dirty Solution:
I tried all suggestions, but I felt there is no better solution. There is no other go, I did a dirty solution to get the right part of the URL completely.

/// <summary>
/// Get Feed URL from raw URL
/// </summary>
/// <param name="rawURL"></param>
/// <returns></returns>
public static string GetFeedURL(string rawURL)
{
    int index = rawURL.IndexOf("=");
    string _rawURL = rawURL;

    if (index > 0)
        _rawURL = _rawURL.Substring(index).Remove(0, 1);

    return _rawURL;
}

Upvotes: 0

Views: 812

Answers (3)

KeithS
KeithS

Reputation: 71565

The URL you provide, while valid, is not going to parse the way you expect; it'll be parsed the way it currently is. Nested query strings are not supported unless the ampersands are encoded.

Upvotes: 0

CoderMarkus
CoderMarkus

Reputation: 1118

You need to URLEncode your URL Variables when adding them to the URL...

url = "http://url.com?id=" + HttpUtility.UrlEncode("...");
Response.Redirect(url);

.. and URLDecode them to work with them after the request...

HttpUtility.UrlDecode(Request.QueryString["id"]);

Otherwise the QueryString request doesn't know how to handle all the extra ?'s and &'s.

Upvotes: 1

mreyeros
mreyeros

Reputation: 4379

It looks like this may be due to the fact that the first "&" character in your FeedUrl may be getting treated as a query parameter for the outside query string. You may need to encode the FeedUrl first. This is just my initial gut feeling.

Upvotes: 2

Related Questions