Reputation: 11652
I am trying to call action from another action by passing parameter values. Url is adding /category?id=1
, but I was expecting /category/1
. Don't know why it is sending with ?id=
.
return RedirectToAction(actionName: "Index", controllerName: "Category",
routeValues: new {id=id});
[HttpGet]
[Route("Admin/Category/{langID:int=0}")]
public ActionResult Index(int langId)
{
--
}
after redirection url is Admin/Category?id=1
MapRoute
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
routes.MapRoute(
name: "AdminPages",
url: "Admin/{controller}/{action}/{id}",
defaults: new { controller = "Category", action = "Index", id = UrlParameter.Optional }
);
routes.MapRoute(
name: "CategoryEdit",
url:"Admin/{controller}/{action}/{id}",
defaults: new { controller = "Category", action = "Index", id = UrlParameter.Optional });
Upvotes: 0
Views: 6171
Reputation: 25370
change your routeValues to routeValues: new { langId = id};
to match your action signature
Upvotes: 1