My Controller:-ForumController
Action:Topic
ViewPage to pass parameter is
<%= Html.ActionLink("Topic", "Topic", "Forum", new { userid = "1" }, null)%>
Controller
public ActionResult Topic(String userid)
{
var topics = new topic { userId = userid };
return View(topics);
}
The parameter is getting passed but instead of getting URL Forum/Topic/1,I am getting Forum/Topic?userid=1;
Can anyone help me out
I suspect that you used the default route in
Global.asaxin which you have{controller}/{action}/{id}.So you should use the same name (
id):and then:
If you don’t want to use
{id}but some other token make sure you adjust your routes accordingly.