简体   繁体   中英

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

Below is the code that I'm using in my aspx page

            <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. Instead of routing to the expected site, it is routing as follows:

http://localhost: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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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