So I've read about routes in MVC and configured according to what's mentioned in other posts.. So my intention is to generate url as below:
http://domain.com/controller/action/id
with this intention I've configured my RoutesConfig.cs as below:
routes.MapRoute(
name: "AdminMessage",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Admin", action = "Messages", id = UrlParameter.Optional }
);
Below is what my Controller looks like
[HttpGet]
public ActionResult Messages(string id)
{
_model = new AdminViewModel();
_userName = Convert.ToString(HttpContext.User.Identity.Name);
ViewBag.Page = "Messages";
_model = PrepareLayoutModel(_userName, "Messages");
return View(_model);
}
And I use Url.Action to generate url as below:
<a href="@Url.Action("Messages", "Admin", new RouteValueDictionary(new {message.MessageID}))"></a>
But it always generates Url as http://domainname/controller/action?messageID=SDc@#123#2@, instead I want to generate it as http://domainname/controller/action/SDc@#123#2@. So what is the way I can get this done?