【问题标题】:Redirect to external url - link works in browser but not redirect method重定向到外部 url - 链接在浏览器中有效,但在重定向方法中无效
【发布时间】:2015-07-16 09:38:48
【问题描述】:

参考.net mvc redirect to external url

因此,您的控制器设置如下所示:

public ActionResult SiteDetails(short id)
{
   return Redirect("localhost:1234/Controller/Action");
}

但是
- 当您调用该操作时,没有任何反应。
- 期待重定向,但没有任何反应。
- 期望重定向到另一个 MVC 站点,但没有任何反应。
- 不仅如此 - 在调试中,当复制到浏览器中时,进入重定向的字符串 url 起作用。

为什么这不起作用?

【问题讨论】:

    标签: asp.net asp.net-mvc


    【解决方案1】:

    在字符串中需要“http://”。

    public ActionResult SiteDetails(short id)
    {
       return Redirect("http://localhost:1234/Controller/Action");
    }
    

    【讨论】:

      猜你喜欢
      • 2012-12-01
      • 2017-05-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-04-03
      • 2020-12-07
      相关资源
      最近更新 更多