ASP.Net MVC重定向到一个不同的视图 [英] ASP.Net MVC Redirect To A Different View

查看:646
本文介绍了ASP.Net MVC重定向到一个不同的视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能重定向到来自控制器的不同看法?例如,在这种情况下,我所有的控制器继承从有,我要重定向到不同的看法,如果某些条件不符合建筑工定制控制器。

Is it possible to redirect to a different view from a controller? For example in this case all my controllers inherit from a custom controller that has a constructer that I want to redirect to different view if certain criteria is not meet.

希望是有道理的。

感谢

推荐答案

您可以RedirectToAction,然后采取行动,你重定向到可以返回一个视图。要做到这一点最简单的方法是:

You can RedirectToAction, then the action you redirect to can return a view. The easiest way to do this is:

return RedirectToAction("Index", model);

然后,在你的指数方法,返回所需的视图。

Then in your Index method, return the view you want.

这篇关于ASP.Net MVC重定向到一个不同的视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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