0

我希望我的网址像:

localhost:22504/Apps/App/{name}/{id}/{type}

所以我将路由值添加到 Global.asax 文件中:

routes.Add("AppRoute", new MyRoute("App/{name}/{id}/{type}", new { controller = "Apps", action = "App" }));
routes.Add("AppRoute2", new MyRoute("App/{id}/{type}", new { controller = "Apps", action = "App" }));

放置在默认路由上方的那些路由如下所示:

routes.MapRoute(
    "Default", // Route name
    "{controller}/{action}/{id}", // URL with parameters
    new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);

我的控制器:

public ActionResult App(string id, string name, string type)
{
    //code here
}

我的网址。操作:

href="@Url.Action("App", "Apps", new { id = GuidEncoder.Encode(app.AppID), name = "Read more", type = "review"})

Url.Action 呈现为:

href="/Apps/App/lBF8BPwVykebNe9XU1KOOg?name=21webmerce-manager1"

我错过了什么?

4

0 回答 0