希望这将让你开始。我可能在这里有几个错误,但它应该很接近。我通常能够做到
@Html.Action("removeObjective", "CPDPlanSurface", new RouteValueDictionary{ {"planId", 123} })
OR
@Html.ActionLink("Click Me!", "removeObjective", "CPDPlanSurface", new RouteValueDictionary{ {"planId", 123} })
我SurfaceController通常是这样的:
using Umbraco.Web.Mvc;
public class CPDPlanSurfaceController : SurfaceController
{
[HttpGet]
public ActionResult removeObjective(int planId)
{
return RedirectToCurrentUmbracoPage();
}
}
到表面控制器的路径最终被类似:
/umbraco/Surface/CPDPlanSurface/removeObjective?planId=123
I相信如果你想要做自己的自定义路由,你需要做这样的事情:
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.MapRoute(
name: "CPDPlanRoutes",
url: "mypage/{action}/{planId}",
defaults: new { controller = "CPDPlanSurface", action = "Index", planId = UrlParameter.Optional });
}
}
,然后ApplicationStarted:
public class StartUpHandlers : ApplicationEventHandler
{
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
RouteConfig.RegisterRoutes(RouteTable.Routes);
}
}
那么你应该能够得到的方法上你的控制器是这样的:
@Url.Action("removeObjective", "CPDPlanSurface")
非常感谢matey。事实证明,我过度思考,你的建议指向了正确的方向。我结束了使用 '@ Html.ActionLink(“Delete Objective”,“removeObjective”,“CPDPlanSurface”,new {@planid = item.PlanID,@userName = Session [“username”],@redirectID = 3660}, null)' 很明显,我对控制器中的ActionResult做了一些更改(更多参数)。 干杯芽 – SxChoc