Question

I have a call from within a table as follows:

td><a href="@Url.Action("EditCourseSection", "Admin", new { courseID = @coursesection.CourseSectionID })"><i class="icon-edit"></i></a></td>

I want this to return a URL of: /Admin/EditCourseSection/1

But it is returning a URL of: /Admin/EditCourseSection?courseID=1

How can I omit the additional parameter details so that simply the variable number is declared after this?

Was it helpful?

Solution

You need to change routing (or add new routing) in your Global.asax as follows:

routes.MapRoute(
                name: "Anyname",
                url: "Admin/{action}/{courseID}",
                defaults: new { controller = "Admin", action = "EditCourseSection", courseID = UrlParameter.Optional}
            );
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top