I have one URL which is “/flexnet/operationsportal/fne/devices/viewDevice?publisherName=test&hostIdType=STRING&hostId=XXXXYYY-XX111-YY333-YYY333-WWW444-KKK999-sriram.kirsh123bc%40test.com&authPartyId=867433&authContactId=”
from this I need to extract only hostId.
Any suggestion how will I do this ?
i need to extract hostId value which is “XXXXYYY-XX111-YY333-YYY333-WWW444-KKK999-sriram.kirsh123bc%40test.com”
Any suggestion would help
If we can rely on its existence it can be done with string functions:
strText.Split("&“c).Where(Function (x) x.StartsWith(“hostId=”)).First().Split(”="c)(1)
thanks it worked, can you please explain a bit more on this function.
I didnt understand this one though I am getting the value.
Thanks in advance
first let me introduce another approach doing it more direct with api
strText = your url string starting with /
myUri = new Uri(“http://dummy.com” + strText)
hostid = HttpUtility.ParseQueryString(myUri.Query).Get(“hostId”)
Retrieve_UriGetParameter.xaml (6.1 KB)
About the statement:
- strText.Split("&“c) -Split by & into a string Array
- Where(Function (x) x.StartsWith(“hostId=”)) - filter the splits on items starting with hostId=
- .First() - take first found item
- .Split(”="c) - split filtered first item on =
- (1) - take second element
thanks for the suggestion, i tried to use HttpUtility before but it was throwing error that " HttpUtility is not a member function of web"
do following for this
close xaml open xaml in editor (e.g. notepad++)
ensure that is present or add:
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.