RedirectToAction for areas?

空扰寡人 提交于 2020-01-04 09:18:55

问题


I have setup some areas, but I'm not sure how to Redirect to them via the RedirectToAction method. There doesn't seem to be any Area parameter I can feed it.

Thanks


回答1:


You will need to use RedirectToRoute if you are trying to redirect to an ActionResult outside the current area. You will first want to make sure you have a route to the ActionResult you would like to redirect to registered for your area. The following article is helpful for this:

http://msdn.microsoft.com/en-us/library/ee307987(VS.100).aspx#registering_routes_in_account_and_store_areas

Once you have routes in place, you can do return RedirectToRoute("MyRouteName");




回答2:


This will work too:

return RedirectToAction("ActionName","ControllerName", new { area = "AreaName" });


来源:https://stackoverflow.com/questions/2846090/redirecttoaction-for-areas

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!