How can I redirect to an index action, but remove "Index/" from the url?
I am currently trying to redirect to the Index of one controller (the
Company controller) from a second controller (the Search controller). In
my Search controller, I have the following code:
RedirectToAction("Index", "Company", new { id = redirectTo.Id, fromSearch
= true, fromSearchQuery = q })
But unfortunately, this takes me to:
/Company/Index/{id}?fromSearch=true&fromSearchQuery={q}
Where fromSearch and fromSearchQuery are optional parameters that are not
always used.
Is there a way to either directly get the URL from RedirectToAction so I
can encase it in a Redirect after I chop out the Index part of the string,
or set up routes with the optional parameters?
No comments:
Post a Comment