简体   繁体   English

ASP.Net C# <asp:Hyperlink> 标记未按预期路由

[英]ASP.Net C# <asp:Hyperlink> tag not routing as expected

Below is the code that I'm using in my aspx page 下面是我在aspx页面中使用的代码

            <asp:HyperLink ID="detaldfjk" runat="server">
                <asp:Label ID="detWebAddr" runat="server" Text=""></asp:Label>
            </asp:HyperLink>

Here is the code in my code-behind page: 这是我的代码隐藏页面中的代码:

        detaldfjk.NavigateUrl = restDetails[0].REST_WEBSITE;
        detWebAddr.Text = restDetails[0].REST_WEBSITE;

The data in the REST_WEBSITE holds,for instance, www.AnotherSite.com. 例如,REST_WEBSITE中的数据包含www.AnotherSite.com。 Instead of routing to the expected site, it is routing as follows: 它不是路由到预期的站点,而是如下路由:

http://localhost:50281/www.AnotherSite.com HTTP://本地主机:50281 / www.AnotherSite.com

Thanks in advance! 提前致谢!

You are not passing a fully qualified url, so the browser appends it to your current url. 您没有传递完全限定的网址,因此浏览器会将其附加到您当前的网址。

You need to add "http://" at the beginning of you url. 您需要在网址的开头添加“http://”。

detaldfjk.NavigateUrl = "http://" + restDetails[0].REST_WEBSITE;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM