I have an action method that looks like this
public ActionResult MethodName(int num)
{
viewmodel model = GetDetails(num)
return View(model);
}
route config looks like this
routes.MapRoute(
name: "MethodName",
url: "{ControllerName}/{MethodName}",
defaults: new {controller = "controllerName", action="MethodName"}
);
My issue is it gives the URL of www.mysite.com/controller/Method?message= 78545
I would like to have it as
www.mysite.com/controller/Method/78545
Can anyone please help me with this? How can I achieve this? I have tried making changes to route config with no help. Do I need to make any URL rewriting or will there be a small fix for this in route config?
Thanks.
[Route(“Method/{num?}”)]