.Net 跳转
Action正常跳转
<a href="@Url.Action("AppDownload")">点击下载APP</a>
public ActionResult AppDownload()
{
return View();
}
RouteUrl路由跳转
<a href="@Url.RouteUrl("RecommandRegister",new { recommandId = ViewData["FriendId"]})">加好友</a>
路由配置
//推荐注册,是一种Get的传参方式
routes.MapLocalizedRoute("RecommandRegister",
"r{recommandId}",
new { controller = "Customer", action = "RecommandRegister" },
new { recommandId = @"[0-9]+"},
new[] { "Nop.Web.Controllers" });
其实跳转的地址是
public ActionResult RecommandRegister(int recommandId)
{
var recommandCustomer = _customerService.GetCustomerById(recommandId);
if (null != recommandCustomer)
{
ViewData["RecommandId"] = recommandId;
ViewData["Recommand"] = GetEnctyPhoneNO(recommandCustomer.Username);
}
return View();
}