区域之外RedirectToAction [英] RedirectToAction outside of Areas

查看:129
本文介绍了区域之外RedirectToAction的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近更新了MVC 2项目在工作中使用,但是我在使用 RedirectToAction 方法有点问题的区域。

我们仍然有一些我们的控制器等我们的区域之外的。这些控制器包括Home控制器等。

我如何做一个 RedirectToAction 从区域内的地区以外的控制器。

我觉得像下面这样可能会工作,但不会:

 返回RedirectToAction(指数,家,新{面积=});

 返回RedirectToAction(指数,家,新的{面积= NULL});


解决方案

看来,我的原始解决方案:

 返回RedirectToAction(指数,家,新{面积=});

确实逸岸的工作。

我不知道我怎么了管理,使之前没有工作,但它似乎是工作像现在的预期。

另外值得一提的是,Visual Studio 2010中还告诉我,无法解决行动索引即使code正常工作。

I've recently updated our MVC 2 project at work to use Areas however I'm having a little problem with the RedirectToAction method.

We still have some of our controllers etc outside of our Areas. These controllers include the Home controller etc.

How do I do a RedirectToAction from inside an Area to a controller outside of Areas.

I thought something like the following might work but doesn't:

return RedirectToAction("Index", "Home", new { area = "" });

or

return RedirectToAction("Index", "Home", new { area = null });

解决方案

It seems that my origional solution:

return RedirectToAction("Index", "Home", new { area = "" });

does infact work.

I'm not sure how I was managing to make it not work before but it seems to be working as expected now.

Also worth noting that Visual Studio 2010 still tells me that Cannot resolve action 'Index' even though the code works fine.

这篇关于区域之外RedirectToAction的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆