Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get url parts without host

Tags:

c#

asp.net

I have a url like this :

http://www.somesite.com/mypage.aspx?myvalue1=hello&myvalue2=goodbye.

I want to get mypage.aspx?myvalue1=hello&myvalue2=goodbye from it . Can you tell me how can I get it ?

like image 556
Rocky Singh Avatar asked Jan 06 '11 20:01

Rocky Singh


2 Answers

Like this:

new Uri(someString).PathAndQuery
like image 159
SLaks Avatar answered Nov 15 '22 11:11

SLaks


var uri = new Uri("http://www.somesite.com/mypage.aspx?myvalue1=hello&myvalue2=goodbye");

string pathOnly = uri.LocalPath;        // "/mypage.aspx"
string queryOnly = uri.Query;           // "?myvalue1=hello&myvalue2=goodbye"
string pathAndQuery = uri.PathAndQuery; // "/mypage.aspx?myvalue1=hello&myvalue2=goodbye"
like image 41
HABJAN Avatar answered Nov 15 '22 11:11

HABJAN