将用户重定向到其他ASP.NET Core Razor网站中的页面 [英] Redirect user to page in a different ASP.NET Core Razor web site

查看:136
本文介绍了将用户重定向到其他ASP.NET Core Razor网站中的页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ASP.NET Core 2.1 Razor应用程序,其中有两个菜单项在登录前处于活动状态.单击任一菜单项时,我想转移(重定向?)到另一个网站.我尝试了重定向,如下所示,但是当前的url被添加到了我指定的字符串中.

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);
    }

我该怎么做?

推荐答案

反正很快就得到了我面前的答案.感谢CodeCaster和Chris Pratt.使用标准网址确实可以正常工作.

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);
    }

这篇关于将用户重定向到其他ASP.NET Core Razor网站中的页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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