質問

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