MVC-RedirectToAction跳转到其他Area

mvc使用Area分区开发后,存在不同Area之间的跳转,需要为每个区间添加Area规则,如下:

复制代码
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" }
            );
        }
    }
}
复制代码

再使用如下语句就可以在不同Area间跳转:

return RedirectToAction("Main", "Frame", new { area = "FrameSet" });

 再传2个参数:

 return RedirectToAction("Main", "Frame", new { area = "FrameSet", a = 2, b = "b" });
?a=2&b=b
posted @ 2016-08-23 19:34  左正  阅读(2042)  评论(0编辑  收藏  举报