mvc使用Area分区开发后,存在不同Area之间的跳转,需要为每个区间添加Area规则,如下:
按 Ctrl+C 复制代码
using System.Web.Mvc; namespace web.Areas.FrameSet { public class FrameSetAreaRegistration : AreaRegistration { public override string AreaName { get { return "FrameSet"; } } public override void RegisterArea(AreaRegistrationContext context) { context.MapRoute( "FrameSet_default", "FrameSet/{controller}/{action}/{id}", new { controller = "Frame", action = "Main", id = UrlParameter.Optional }, new string[] { "web.Areas.FrameSet.Controllers" } ); } } }
按 Ctrl+C 复制代码
再使用如下语句就可以在不同Area间跳转:
return RedirectToAction("Main", "Frame", new { area = "FrameSet" });
再传2个参数:
return RedirectToAction("Main", "Frame", new { area = "FrameSet", a = 2, b = "b" });
?a=2&b=b
原文地址:http://www.cnblogs.com/yaosuc/p/4532975.html