【问题标题】:Redirection to another website in razor application在剃须刀应用程序中重定向到另一个网站
【发布时间】:2013-09-09 09:33:17
【问题描述】:

我想在我的 Asp.net mvc4 应用程序中添加一个指向google.com 的链接。所以我将这个 sn-p 添加到我的视图中:

 <p class="art-page-footer">
        <span id="art-footnote-links"><a href="www.google.com" target="_blank">google.com</a></span>
    </p>

当我点击此链接时,我的网址为 http://localhost:61961/User/www.google.com,但我有一个例外。

那么为什么这个重定向不起作用呢?如何修复我的代码?

【问题讨论】:

  • 你试过href="http://www.google.com"吗?
  • 是的,现在可以使用了!!有什么区别?
  • MVC 路由到 con 控制器,请参阅 ASP.MVC 中路由的一些教程。
  • 您的 href 指向您网站内的资源。使用 http 前缀,它可以跳出起始域。
  • @AlessandroD'Andria : 你能把你的评论作为答案吗

标签: c# asp.net .net asp.net-mvc asp.net-mvc-4


【解决方案1】:

尝试完整的网址:

<a href="http://www.google.com" target="_blank">

【讨论】:

    【解决方案2】:

    href 属性采用链接的URL

    3 个可能的值:

    1. 绝对 URL :指向另一个网站(例如 href="http://www.google.com")
    2. 相对 URL :指向网站内的文件(如 href="contacts.html")
    3. 锚点 URL :指向页面中的锚点(如 href="#top")

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-12-04
      • 1970-01-01
      • 2019-05-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-07-16
      相关资源
      最近更新 更多