Trying to join a list of strings together using string.join. When I use the Separator string " OR " the white spaces are being replaced with "+" which is breaking my targetUri string. Below is the code used to join.
if (DocumentSearchListViewModel.Filter == null)
{
return "http://000.000.00.00:8080/value/value/search/json?terms=value%20OR%20value&target=TEST2&maxResults=5";
}
var targetUri = "http://000.000.00.00:8080/value/value/search/json?";
NameValueCollection termsString = System.Web.HttpUtility.ParseQueryString(string.Empty);
if (!string.IsNullOrWhiteSpace(DocumentSearchListViewModel.Filter.Keywords))
{
if (!string.IsNullOrWhiteSpace(DocumentSearchListViewModel.Filter.Author))
{
DocumentSearchListViewModel.Filter.Keywords += (" " + DocumentSearchListViewModel.Filter.Author);
}
IList<string> keywords = DocumentSearchListViewModel.Filter.Keywords.Split();
termsString["terms"] = string.Join(" OR ", keywords);
}
targetUri += termsString.ToString();
targetUri += "&target=TEST2&maxResults=";
targetUri += DocumentSearchListViewModel.Filter.MaxNumberOfResults ?? "5";
return targetUri;
I have done many searches on Google but haven't been able to find anything that talks about string.join replacing characters. And during my debugging I was able to narrow it down to on the termsString line as where the problem occurs.
Here is an actual example of the string I get out: terms=value1+OR+value2+OR+value3
How would I stop the white spaces from being replaced with + characters?
Cheers,
James