tags:

views:

366

answers:

2

I need a certain part of current URL.
Say for example the URL is: http://www.abc.com/123/product/234?productid=123
And I want to check if a certain string contains http://www.abc.com/123

Please don't give answers like "do string manipulation" and all. Is there a way to get this sort of URL?

A: 
string myString = "http://www.abc.com/123/product/234?productid=123";
bool contains = myString.Contains("http://www.abc.com/123");
Daniel A. White
I want to write a generalize code !!! I hoped that is self-understod. It was just an example, please don't go by the values provided in example and think in general.
Manish
What if I try http://www.xyz.com/http://www.abc.com/123 ? that still passes the test!
David Kemp
What do you mean by generalizing it?
Daniel A. White
+1  A: 

The Uri class has some really helpful methods for Uri mangling - including Uri.TryCreate.

Specifically, the GetComponents method might help you.

David Kemp
Good information but couldn't found something in this which can help me.
Manish