Reputation: 3447
I already have a route in the RouteConfig
, to redirect to the Archive
Action when there is a year and a month :-
routes.MapRoute("Blog", "Blog/{action}/{id}",
new
{
controller = "Blog",
action = "show",
id = ""
});
Now I wish to have another MapRoute
that redirect to the Archive
Action when there is a category, for example Blog/Archive?catId=2
.
How can I achieve that?
Upvotes: 0
Views: 156
Reputation: 656
In your RouteConfig you can add
routes.MapRoute("Archive", "Blog/Archive", new {controller = "Blog", Action = "Archive" });
In you controller you can have this action
public void Archive(int catId) {
...
}
This will automatically map catId query string value to the catId variable.
Upvotes: 1