سؤال

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