473,806 Members | 2,611 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

asp:Hyperlink NavigateUrl problem

I have a page that has an asp:Hyperlink control on it.
The NavigateUrl is set to "~/Aaa/Bbb.aspx"
When the link is rendered it is rendered as Aaa/Bbb.aspx which I would think
is completely incorrect.

As I understand the use of the this syntax , ~ should be replaced by the
application path.
so for an application in the root this value should be /Aaa/Bbb.aspx
for an application in the /Ccc/Ddd directory this should be
/Ccc/Ddd/Aaa/Bbb.aspx

I have a site which directs requests to /Default.aspx via url rewriting
the problem is for an url http://site/xxx/yyy/xxx.aspx that is rewritten to
http://site/default.aspx,
the link ends up with a effective href of http://site/xxx/yyy/Aaa/Bbb.aspx
whereas I would expect it to be http://site/Aaa/Bbb.aspx regardless of the
url of the page on which it appears
- is not the whole point of ~/ to make an url relative to the application
root rather than relative to the current page ?

Is this a bug in the Hyperlink control rendering ?
Or do I completely misunderstand the purpose of the ~/ syntax ?

Gerry

Jan 18 '06 #1
2 3447
You probably have http://site/xxx/yyy set as an application, so it will be
treated as an application path when using "~". If it's possible, you might
eliminate the above as an application in IIS and then see what happens. (Of
course, if this subweb is relying on a web.config, then you may not be able
to do it this way.)
--
Christopher A. Reed
"The oxen are slow, but the earth is patient."

"gerry" <ge**@canada.co m> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
I have a page that has an asp:Hyperlink control on it.
The NavigateUrl is set to "~/Aaa/Bbb.aspx"
When the link is rendered it is rendered as Aaa/Bbb.aspx which I would
think
is completely incorrect.

As I understand the use of the this syntax , ~ should be replaced by the
application path.
so for an application in the root this value should be /Aaa/Bbb.aspx
for an application in the /Ccc/Ddd directory this should be
/Ccc/Ddd/Aaa/Bbb.aspx

I have a site which directs requests to /Default.aspx via url rewriting
the problem is for an url http://site/xxx/yyy/xxx.aspx that is rewritten
to
http://site/default.aspx,
the link ends up with a effective href of http://site/xxx/yyy/Aaa/Bbb.aspx
whereas I would expect it to be http://site/Aaa/Bbb.aspx regardless of the
url of the page on which it appears
- is not the whole point of ~/ to make an url relative to the application
root rather than relative to the current page ?

Is this a bug in the Hyperlink control rendering ?
Or do I completely misunderstand the purpose of the ~/ syntax ?

Gerry

Jan 21 '06 #2
No , in this case the only IIS application is the root , in fact
http://xxx/yyy doesn't even exist as far as IIS is concerned and there is no
'subweb'. EVERYTHING is rewritten to /Default.aspx, it is the only thing in
the website.
Although I do agree with your assessment of how ~/ should work
To be safe , .net should always be generating the url from the application
root ie. /xxx/yyy/Aaa/Bbb.aspx. but it seems as if it is trying to generate
an url relative to the current page which is fine if it is done right - but
its not. I ran into this situation myself when trying to generate urls
relative to the current page using a custom sitemap - I found that you have
to use Request.RawUrl as the base reference instead of Request.Url. in this
example RawUrl would be /xxx/yyy/xxx.apsx whereas Url would be /Default.aspx
so for /xxx/yyy/xxx.aspx the link should be to /Aaa/Bbb.aspx as the 2 urls
are unrelated
for /Default.aspx the link should be Aaa/Bbb.aspx as the 2 urls are related
at the root

Gerry

"Christophe r Reed" <ca****@nospam. nospam> wrote in message
news:eQ******** ******@TK2MSFTN GP10.phx.gbl...
You probably have http://site/xxx/yyy set as an application, so it will be
treated as an application path when using "~". If it's possible, you might eliminate the above as an application in IIS and then see what happens. (Of course, if this subweb is relying on a web.config, then you may not be able to do it this way.)
--
Christopher A. Reed
"The oxen are slow, but the earth is patient."

"gerry" <ge**@canada.co m> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
I have a page that has an asp:Hyperlink control on it.
The NavigateUrl is set to "~/Aaa/Bbb.aspx"
When the link is rendered it is rendered as Aaa/Bbb.aspx which I would
think
is completely incorrect.

As I understand the use of the this syntax , ~ should be replaced by the
application path.
so for an application in the root this value should be /Aaa/Bbb.aspx
for an application in the /Ccc/Ddd directory this should be
/Ccc/Ddd/Aaa/Bbb.aspx

I have a site which directs requests to /Default.aspx via url rewriting
the problem is for an url http://site/xxx/yyy/xxx.aspx that is rewritten
to
http://site/default.aspx,
the link ends up with a effective href of http://site/xxx/yyy/Aaa/Bbb.aspx whereas I would expect it to be http://site/Aaa/Bbb.aspx regardless of the url of the page on which it appears
- is not the whole point of ~/ to make an url relative to the application root rather than relative to the current page ?

Is this a bug in the Hyperlink control rendering ?
Or do I completely misunderstand the purpose of the ~/ syntax ?

Gerry


Jan 22 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
8957
by: Amir Eshterayeh | last post by:
Dear Friends My asp hyperlink goes to relative address instead of absolute. I like navigate url goes to outsite link like www.asp.net but now, it goes to www.mysite/www.asp.net please help. I create the navigatURL from database dynamically. I see the same question mentioned here but the response is not souitable for me: http://www.dotnet247.com/247reference/msgs/11/57708.aspx
4
4398
by: James P. | last post by:
Hello there, I have an asp hyperlink in a template page. In my user control page - code behind page that uses the template, I'd like to turn this link invisible in certain case. Is it possible? This is my hyperlink: <asp:HyperLink id="hplShoppingCart" runat="server" Font-Size="Larger" Font-Names="Arial" NavigateUrl="../forms/ProductOrder.aspx?fn=c">Shopping Cart</asp:HyperLink>
5
6693
by: Martin Dew | last post by:
Having some problems getting a hyperlink object to work in my repeater control, It displays the text I have asked it to for the hyperlink, but it does not act as a link. My repeater code is below but here is the snippet of my asp:hyperlink object; <asp:HyperLink NavigateUrl="authonly/clientdetails.aspx?searchID="+<%#DataBinder.Eval(Conta iner.DataItem,"CLIENTREF")%> ID="Hyperlink1"><%#DataBinder.Eval(Container.DataItem,...
3
1602
by: MrMike | last post by:
I have the following hyperlink webcontrol. The problem is that I can't figure out how to pass the webform's Request.Querystring("id") param into the NavigateURL as shown below. As it is currently formatted the hyperlink appears but I can't click on it. Could someone please let me know how to format this correctly? <asp:HyperLink id="hlBarcodes" style="Z-INDEX: 112; LEFT: 465px; POSITION: absolute; TOP: 115px" runat="server"...
2
1500
by: MrMike | last post by:
I am attempting to pass a parameter named "BackURL" into a asp:Hyperlink HTML control as shown below. "BackURL" is actually a variable defined in the page's code-behind. However, my current formatting below causes a "Page cannot be displayed" error, and is invalid. How can I properly reference my BackURL variable in the NavigateURL property of the asp:Hyperlink control? Thanks. <asp:HyperLink runat="server" Text="Update"...
9
2720
by: Leon | last post by:
What Am I Doing Wrong? Code Will Not Run, I Can't See The Error! Thanks. <asp:datalist id="DataList1" runat="server" RepeatColumns="4"> <ItemTemplate> <asp:HyperLink id=HyperLink1 ImageUrl= '<%# String.Format("Toyota/Images/Showroom/" & Container.DataItem("PathToDisplyPic"))%>' NavigateUrl='<%#
4
2220
by: Satya | last post by:
Hi all, The following code is throwing a run time error "The server tag is not well formed. " <ItemTemplate> <asp:HyperLink Runat="server" ID="lnkFile" NavigateUrl="javascript:OpenImage('<%# DataBinder.Eval(Container.DataItem,"FileName") %>');"><%#
1
2182
by: illmagination | last post by:
Hi, I need to display a small pop up message warning the user is leaving the website. At the same time I need to also keep track of who is leaving the website. My problem is that I can't user javascript in asp:hyperlink tags. Should I just use a regular <atag and include the IDs and Runat=Server tags? Here is my code
7
7048
by: ashtek | last post by:
I have an <ASP:HYPERLINKon a datagrid (templatecolumn) and I need to open a new window with no toolbar and specific height & width onclick of the link. I also want to pass the PK to this new window. <ASP:HYPERLINK ID="lnkNewWin" RUNAT="server" NAVIGATEURL="#" ONCLICK="javascript:window.open('NewWin.aspx?PK=<%# DataBinder.Eval(Container.DataItem,"PK")%>','','toolbar=0,width=600,height=600,scollbars=1')" TEXT="Click"></ASP:HYPERLINK> ...
2
2815
by: BobLaughland | last post by:
Hi There, I need a control on my site that is a hyperlink style control, but it must, 1) Have a property that can hold where the hyperlink is pointing to. (e.g. like the NavigateUrl property in the asp:hyperlink control). 2) Also can call my own method when the user clicks on the link (e.g. like the Click event in the asp:linkbutton control).
0
9719
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10623
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10373
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10111
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9192
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5546
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5683
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3852
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3010
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.