when I use the following actionlink:
<%: Html.ActionLink("Study Cases", "Index", "CourseCases", new { id = Model.ID }, new { @class = "t-button", @style = "width:240px; color:white; text-align:center" })%>
The url address in the browser is:
http://localhost:11111/CourseCases/Index/9
How can I change it so the url will be
http://localhost:11111/CourseCases?courseId=9
It works when I use:
return RedirectToAction("Index", "CourseCases", new { courseId = id });
in the controller.
Thanks in adance.
Like this:
The reason why your code generates
http://localhost:11111/CourseCases/Index/9is because the{id}is used by the default route that was generated when you created your ASP.NET MVC 3 application, so when you specifyid = Model.IDit will match the route pattern definition in your Global.asax which is{controller}/{action}/{id}thus you getCourseCases/Index/9.