从ASP.NET MVC控制器重定向到外部URI [英] Redirect to external URI from ASP.NET MVC controller

查看:1426
本文介绍了从ASP.NET MVC控制器重定向到外部URI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从一个操作方法重定向到外部URL,但不能让它开始工作。任何人都可以提供一些线索在我的错误?

I'm trying to redirect to external url from an action method but can't get it to work. Can anybody shed some light on my error?

public void ID(string id)
    {
        string url = string.Empty;
        switch (id)
        {
            case "DB2FCB11-579F-4DA2-A68C-A6495B9BAAB5":

                url = "http://www.somesite.com";
                break;
        }
        Response.Redirect(url, true);
    }

谢谢,
克里斯

Thanks, Chris

推荐答案

如果你谈论的是ASP.NET MVC,那么你应该有一个返回下面的一个控制器方法:

If you're talking about ASP.NET MVC then you should have a controller method that returns the following:

return Redirect("http://www.google.com");

否则,我们需要你在重定向得到错误的详细信息。我想步,以确保URL不为空。

Otherwise we need more info on the error you're getting in the redirect. I'd step through to make sure the url isn't empty.

这篇关于从ASP.NET MVC控制器重定向到外部URI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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