gpt4 book ai didi

c# - ASP.NET MVC 3 - 重定向到另一个操作

转载 作者:IT王子 更新时间:2023-10-29 03:42:19 26 4
gpt4 key购买 nike

我想将 Home Controller 的 Index 操作重定向到另一个 Controller 的操作,仅此而已。因此我的代码是:

    public void Index()
{
//All we want to do is redirect to the class selection page
RedirectToAction("SelectClasses", "Registration");
}

现在,这只是加载一个 0 kB 的空白页面,什么都不做。我觉得它与 void 返回类型有关,但我不知道还能将其更改为什么。这里有什么问题?

最佳答案

您的方法需要返回一个 ActionResult 类型:

public ActionResult Index()
{
//All we want to do is redirect to the class selection page
return RedirectToAction("SelectClasses", "Registration");
}

关于c# - ASP.NET MVC 3 - 重定向到另一个操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4909670/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com