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?

Était-ce utile?

La 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}
            );
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top