在浏览器 MVC c# 中更改路由

Changing route in browser MVC c#

我有一个小问题,如果有人能帮助我,我会很高兴。

我正在从大学创建一个项目,在菜单中我引用了另一个网站。我在家庭控制器中使用方法 Redirect 是这样的:

    public ActionResult MyReference()
    {
        ViewBag.Current = "MyReference";
        return Redirect("linktootherwebsite.com");
    }

它工作正常,但是当我将鼠标放在参考上(悬停)时,我得到了我删除的旧视图的路径,我的意思是:

我得到了:

Home/MyReference

但我想要

Home/linktootherwebsite.com

甚至:

linktootherwebsite.com

感谢所有帮助。 最良好的祝愿。 :)

然后只需将此添加到您的RouteConfig.cs之前默认路由:

routes.MapRoute(
    name: "whatever",
    url: "Home/linktootherwebsite.com",
    defaults: new
    {
        controller = "Home",
        action = "MyReference",
    }
);