Redirect user to page in a different ASP.NET Core Razor web site

落爺英雄遲暮 提交于 2019-12-10 22:49:34

问题


I have an ASP.NET Core 2.1 Razor app with two menu items that are active prior to login. I want to transfer (redirect?) to a different web site when either of the menu items is clicked. I've tried a Redirect, as shown below, but the current url is added to the string I specify.

    public IActionResult OnGet()
    {
        string url = "www.google.com";

        return Redirect(url);
    }

How can I do this?


回答1:


It didn't take long to get the answer that was right in front of me anyway. Thanks to CodeCaster and Chris Pratt. Using a fully-qualified URL does work correctly.

        public IActionResult OnGet()
    {
        string url = "https://www.google.com";

        return Redirect(url);
    }


来源:https://stackoverflow.com/questions/50875794/redirect-user-to-page-in-a-different-asp-net-core-razor-web-site

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!