I have an action link in HTML.
<a href="@Url.Action("UserWisedPost", "Blog", new { userName = item.UserName,userId=item.UserId })">@item.UserName</a>
In controller,
public ActionResult UserWisedPost(string userId,string userName, int? page, int pageSize = 10)
{
page = page == null || page == 0 ? 1 : page;
var model = _post.GetByUserId(userId).ToPagedList((int)page, pageSize);
return View(model);
}
And in RouteConfig
routes.MapRoute(
name: "userwisedPost",
url: "{controller}/{action}/{userName}",
defaults: new { controller = "Blog", action = "UserWisedPost", userName=UrlParameter.Optional}
);
You have probably understood what I want to mean. I want to display URL like ../UserWisedPost/userName
but want access data by userId
in controller.
How can I do that?