我怎样才能重定向我的行动,以网站的根? [英] How can I redirect my action to the root of the web site?

查看:99
本文介绍了我怎样才能重定向我的行动,以网站的根?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下的code在我的控制器来重定向我的用户,他注销之后:

I have the following code in my controller to redirect my user after he has logged out:

public ActionResult Logout()
        {
            FormsAuthentication.SignOut();
            return new RedirectToRouteResult(
                new RouteValueDictionary(
                    new {
                        area = "Administration",
                        controller = "Menus", 
                        action = "Home" 
                    }
                )
            );
        }

我想将用户重定向到/或我的网站基本URL(根)。有没有一种方法
我能做到这一点,而无需给予该地区,控制器和动作的细节?

I would like to redirect the user to / or the base URL (root) of my site. Is there a way that I can do this without having to give details of the area, controller and action?

推荐答案

如果你不想使用 RedirectToAction (对我来说是正确的选择)
你可以使用

if you don't want to use RedirectToAction (for me is the right choice) you can use

return Redirect(Url.Content("~/"));

这篇关于我怎样才能重定向我的行动,以网站的根?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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