Ich brauche diese URL http://localhost:53249/Admin/EditPosts/1/Edit
aber leider im Query-String in URL bekommen wie diese http://localhost:53249/Admin/EditPosts?id=1&operation=Edit
Action zeigt Parameter in URL anstelle von Abfragezeichen mvc
Das ist mein Actionlink ist (Anker-Tag)
<td>@Html.ActionLink(@posts.Title, "EditPosts", "Admin", new { id = posts.id, operation="Detail" }, null)</td>
Dies ist Meine Route Konfig:
public static void RegisterRoutes(RouteCollection routes)
{
//routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapMvcAttributeRoutes();
routes.MapRoute(
name: "Admin",
url: "Admin/EditPosts/{id}/{operation}",
defaults: new { controller = "Admin", action = "EditPosts"}
);
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
Dank @guilherme aber nach, dass die URL ich bin immer wie diese http: // localhost: 53249/Admin/Beiträge/1/Beiträge ? operation = Bearbeiten –
Versuchen Sie mit Aktion Link wie folgt: @ Html.ActionLink (@ Beiträge.Titel, "Bearbeiten", "Beiträge", neue {ID = Posts.id}, null) – Guilherme
aber ich habe 2 Parameter zuerst Einer ist id und der zweite ist Operation (bearbeiten, Details) –