Вопрос

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?

Это было полезно?

Решение

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}
            );
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top