ASP.NET MVC 3 - 重定向到另一个动作 [英] ASP.NET MVC 3 - redirect to another action
本文介绍了ASP.NET MVC 3 - 重定向到另一个动作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想重定向Home控制器到另一个控制器的动作并没有别的Index操作。我的code是这样的:
I want to redirect the Index action of the Home controller to another controller's action and nothing else. My code is thus:
public void Index()
{
//All we want to do is redirect to the class selection page
RedirectToAction("SelectClasses", "Registration");
}
现在,这只是加载一个0 KB空白页和什么都不做。我有这事做与返回类型为void的感觉,但我不知道还有什么将其更改为。什么是这里的问题?
Right now, this just loads a 0 kB blank page and does nothing. I have a feeling it has something to do with that void return type, but I don't know what else to change it to. What's the issue here?
推荐答案
您的方法必须返回一个的ActionResult
键入
Your method needs to return a ActionResult
type:
public ActionResult Index()
{
//All we want to do is redirect to the class selection page
return RedirectToAction("SelectClasses", "Registration");
}
这篇关于ASP.NET MVC 3 - 重定向到另一个动作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文