简体   繁体   中英

Get specific data from URI

I wanted to get the following data from the url

  1. the service name which is in this case - customer

2.client which is 177

the structure is the the same always and the name of the service and client can be changed

Uri uri = new Uri("https://ldcorp:435/mtp/op/ota/ind/Customer/?my-client=177");

uri.Segments.LastOrDefault() returns "Customer/"

uri.Query returns "?my-client=177"

You can use HttpUtility.ParseQueryString (System.Web assembly) to parse the query.

var result = HttpUtility.ParseQueryString(uri.Query);
string client = result["my-client"];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM