Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > asp:Hyperlink NavigateUrl problem

Reply
Thread Tools

asp:Hyperlink NavigateUrl problem

 
 
gerry
Guest
Posts: n/a
 
      01-18-2006
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



 
Reply With Quote
 
 
 
 
Christopher Reed
Guest
Posts: n/a
 
      01-21-2006
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" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
>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
>
>
>



 
Reply With Quote
 
 
 
 
gerry
Guest
Posts: n/a
 
      01-22-2006
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



"Christopher Reed" <(E-Mail Removed)> wrote in message
news:eQG2I#(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
> >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
> >
> >
> >

>
>



 
Reply With Quote
 
Sobot Sobot is offline
Junior Member
Join Date: Feb 2009
Location: Belgrade
Posts: 3
 
      02-13-2009
May be off topic but still relevant...

For tje problem of absolute url binding to NavigateURL field of asp:HyperLink
Solution is to use Page_PreRender method to do the binding because it will be overwritten if you do it Page_OnLoad

can find more here
asp:HyperLink NavigateUrl Problem Absolute URL

Link: sobot-software.blogspot.com/2009/02/asphyperlink-navigateurl-problem.html

Sobot Software DotNetNuke Outsourcing
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
problem with NavigateUrl Jeff ASP .Net 0 01-31-2010 08:33 AM
hyperlink and dynamically formed NavigateURL problem Tomek R. ASP .Net 7 02-13-2009 05:12 PM
Problem setting NavigateUrl's in DataList (hyperlink) VB Programmer ASP .Net 3 11-16-2005 12:29 AM
Problem with Hyperlink.NavigateURL="../../" in WebControls Christoph Schuster ASP .Net Web Controls 4 07-23-2003 09:05 AM
NavigateUrl problem Helixpoint ASP .Net 0 07-22-2003 05:42 PM



Advertisments