You do not need two routes, because you provide the search parameters as a query string. Only one search route:
routes.MapRoute( "Search", "Search", new { controller = "Search", action = "Search" } );
Then write this controller action
public ActionResult Search(int? type, string q) { var defaultType = type.HasValue ? type.Value : 1; if (string.IsNullOrEmpty(q)) {
The body of this method depends heavily on the search condition, whether you need both parameters when searching for material or just q , and you have a default for type . Remember that page indexing can be done exactly the same.
Using strong type parameters (validation)
Of course, you can create a class that can be checked, but the property names should reflect the query string. So you will have a class:
public class SearchTerms { public int? type { get; set; } public string q { get; set; } }
And use the same query with the same query variables as you currently have, or have a clean class and adjust your query:
public class SearchTerms { public int? Type { get; set; } public string Query { get; set; } } http:
Robert Koritnik
source share