Reputation: 1337
I'm using the following url and I need to delete the ?$format=xml from the url. Is there a simple way to achieve this ?
Uri uri = new Uri("https://ldcorp:435/mtp/op/ota/ind/Customer/?$format=xml);
Upvotes: 0
Views: 181
Reputation: 460048
Maybe with simple string methods:
uriString = uri.ToString();
int indexOfQuestionMark = uriString.IndexOf("?");
if(indexOfQuestionMark >= 0)
{
uri = new Uri(uriString.Substring(0, indexOfQuestionMark));
}
or with the Uri
class itself and string.Format
:
string pathWithoutQuery = String.Format("{0}{1}{2}{3}", uri.Scheme,
uri.Scheme, Uri.SchemeDelimiter, uri.Authority, uri.AbsolutePath);
uri = new Uri(pathWithoutQuery);
Upvotes: 2