Jean Tehhe
Jean Tehhe

Reputation: 1357

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");

Upvotes: 2

Views: 99

Answers (1)

Dirk
Dirk

Reputation: 10968

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"];

Upvotes: 4

Related Questions