asp.net-mvc - 如何重定向到同一 Controller 中的另一个 Action ?

标签 asp.net-mvc asp.net-mvc-3 redirect controller action

我想重定向到同一 Controller 中的另一个 Action 。
我们怎样才能做到这一点?
我试着喜欢回来

RedirectToAction("NotAuthorized");

最佳答案

return RedirectToAction("ActionName");

代替return Redirect("/Elearning/NotAuthorized");这样做:
return RedirectToAction("NotAuthorized"); // if you're inside the Elearning controller

或者
RedirectToAction("NotAuthorized", "Elearning"); // if calling from other controller

关于asp.net-mvc - 如何重定向到同一 Controller 中的另一个 Action ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10353931/

相关文章:

apache - 从 Apache VirtualHost 将 HTTPS 永久重定向到 HTTP

c# - 为另一个时区的服务器调整 DateTime.Now

jquery - 使用 Ajax 时 reCaptcha 不会重新加载

c# - 大括号关闭时出现 NullReferenceException

c# - 如何从 mvc3 模型的序列化 json 中获取backbone.js 模型?

.htaccess - 我可以使用 .htaccess 规则对网站使用通配符,然后重写特定页面吗?

c# - 有没有比通过 ASP.NET MVC 中的 ViewModel 使用多个模型更好的方法?

mysql - 在 MVC3 和 MySQL 中使用 EF4.1 Code First 的问题

asp.net-mvc-3 - 将图像放在 CDN 上,在 IIS7 上使用 MVC3

javascript - 下载文件并重定向...或替代