I'm trying to do something similar to what Stackoverflow is doing.
I have a quick search text box and I can put an arbitrary number of words into in and submit my search. Receiving action does this (shortened version)
public ActionResult Search(string query)
{
Regex rx = new Regex("(?<word>[a-zA-Z0-9]+)");
StringBuilder parts = new StringBuilder();
foreach(Match m in rx.Matches(query))
{
parts.Append(parts.Length > 0 ? "+" : string.Empty);
parts.Append(m.Groups["word"]);
}
return RedirectToAction("Search", new { query = parts.ToString() }); ;
}
But instead of
http://localhost/search?query=word+word
I see
http://localhost/search?query=word%2Bword
Stackoverflow does something very very similar and I'd like the do the same. I don't want my pluses escaped in my URLs. but I would still like to use RedirectToAction
if possible.