I'm currently working with Umbraco 6.1.6 and some mvc views and controllers. What I try to do is the following:
In my razor view I have the following line to create an actionlink:
@Html.ActionLink("Klik to search...", "Search", "Search", new { SearchText = "searchterm" }, null)
The actionlink fires the Search method of the SearchController (is a SurfaceController):
public ActionResult Search(string SearchText)
{
if (String.IsNullOrEmpty(SearchText))
{
return RedirectToCurrentUmbracoPage();
}
SearchResult result = SearchManager.Instance.Search(SearchText);
return View("SearchResults", result);
}
When I use an textbox and an submit button in an Html.BeginUmbracoForm this works well but when I use Html.ActionLink the RedirectToCurrentUmbracoPage throws an exception ( Cannot find the Umbraco route definition in the route values, the request must be made in the context of an Umbraco request ) and the results page does not use the specified style template.
How can I force the ActionLink to be made in the context of an Umbraco request? And does that bring back the styling like the other Umbraco pages?
Thank you for your time!