MVC-RedirectToAction跳转到其他Area
生活随笔
收集整理的這篇文章主要介紹了
MVC-RedirectToAction跳转到其他Area
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
mvc使用Area分區(qū)開(kāi)發(fā)后,存在不同Area之間的跳轉(zhuǎn),需要為每個(gè)區(qū)間添加Area規(guī)則,如下:
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" });}} }再使用如下語(yǔ)句就可以在不同Area間跳轉(zhuǎn):
return RedirectToAction("Main", "Frame", new { area = "FrameSet" });?再傳2個(gè)參數(shù):
return RedirectToAction("Main", "Frame", new { area = "FrameSet", a = 2, b = "b" }); ?a=2&b=b總結(jié)
以上是生活随笔為你收集整理的MVC-RedirectToAction跳转到其他Area的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 缓存写法总结
- 下一篇: MVC UpdateModel的未能更新