In my asp.net-mvc ontroller I accept a bunch of form field values and from those create a string the Lucene library understands. Then I want to redirect to a get method that will show results depending on this lucene string.
The lucene string is in the pattern {fieldName1:value1 fieldName2:value2 ...}
my Global.asax has the following entry for the redirect target:
routes.MapRoute(
"AdvancedSearch",
"AdvancedSearch.mvc/{displayType}/luceneString",
new { controller = "Search", action = "AdvancedSearch",
displayType = "chip", luceneString = "" }
);
So my controller catches the post, creates the luceneString and does the following:
return RedirectToRoute("AdvancedSearch", new
{
Controller = "Search",
action = "AdvancedSearch",
displayType = "chip",
queryString = Url.Encode("company:test name:testname")
});
This gives me a 500: bad request.
Even with one parameter it doesn't work. Even with the ":" it doesn't work.
I tried:
- AdvancedSearch.mvc/chip/company%3Atest+name%3AtestName
- AdvancedSearch.mvc/chip/company:test+name:testName
- AdvancedSearch.mvc/chip/company:test
- AdvancedSearch.mvc/chip/company%3Atest
It only works if I change this url to take the queryString in the format of
AdvancedSearch.mvc/chip?q=company%3Atest+name%3AtestName
What should I do to get the encoding right without resorting to "?q="
If I have to use the querystring, how can I define such a thing in the route table? How do I go about to call redirect to it?