开发者

Get url parts without host

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 this:

new Uri(someString).PathAndQuery


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"


Place your string URL into a URI object and then use the AbsolutePath & Query properties to get the URL parts you need.

Or use the PathAndQuery property to get both, which is what you need.

More information can be found here:

http://msdn.microsoft.com/en-us/library/system.uri_members%28v=VS.71%29.aspx


new Uri(System.AppDomain.CurrentDomain.BaseDirectory).Segments

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜