Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Reference to Virtual Root path not working

Reply
Thread Tools

Reference to Virtual Root path not working

 
 
John Kotuby
Guest
Posts: n/a
 
      05-23-2007
Hi all..

In a VS2005 ASP.NET 2.0 website application I am using a regular HTML anchor
(actually a number of them) in a page that produces Excel output because a
server control is really not needed here. I am using a relative path in the
anchor such as:
<a href= "/Common/ListView.aspx"

My understanding is that I cannot use the syntax:

<a href="~/Common/ListView.aspx"

....if I am not declaring a Server control. Maybe I am wrong there... but
anyway...

I want to create in Global.asax a session variable - UrlRoot - that I can
reference anywhere in the application that holds the virtual root whether
the app is running on my dev machine, a local testing server, or the remote
production server like so ...

<a href= UrlRoot & "/Common/ListView.aspx"

I have tried:
Session.Add("URL_Root", "http://" & Request.Url.Host)
Session.Add("URL_Root", "http://" &
HttpContext.Current.Request.ApplicationPath)
Session.Add("URL_Root", VirtualPathUtility.ToAppRelative("/"))

No matter what method I use or where I run the app the link dynamically
created in the Excel file seems to be returning:

http://localhost/Common/ListView.aspx
rather than
http://www.prodserv.com/Common/ListView.aspx

Can anyone lend assistance? I need the URL_Root to return the root domain of
what the User would type into the browser to get to the correct page.
Thanks...


 
Reply With Quote
 
 
 
 
Aidy
Guest
Posts: n/a
 
      05-23-2007
> <a href= "/Common/ListView.aspx"

use

<asp:Hyperlink ID="myLink" NavigateUrl="~/Common/ListView.aspc"
runat="server">click here</asp:Hyperlink>


 
Reply With Quote
 
 
 
 
Aidy
Guest
Posts: n/a
 
      05-23-2007
PS syntax is off the top of my head, not sure if that's write. Basically
use a Hyperlink control rather than an anchor tag.

"Aidy" <> wrote in message
news:...
>> <a href= "/Common/ListView.aspx"

>
> use
>
> <asp:Hyperlink ID="myLink" NavigateUrl="~/Common/ListView.aspc"
> runat="server">click here</asp:Hyperlink>
>



 
Reply With Quote
 
SAL
Guest
Posts: n/a
 
      05-23-2007
Have you tried:
Session.Add("URL_Root", Server.MapPath(""))

Not sure if you can use it but maybe...

S

"John Kotuby" <> wrote in message
news:...
> Hi all..
>
> In a VS2005 ASP.NET 2.0 website application I am using a regular HTML
> anchor (actually a number of them) in a page that produces Excel output
> because a server control is really not needed here. I am using a relative
> path in the anchor such as:
> <a href= "/Common/ListView.aspx"
>
> My understanding is that I cannot use the syntax:
>
> <a href="~/Common/ListView.aspx"
>
> ...if I am not declaring a Server control. Maybe I am wrong there... but
> anyway...
>
> I want to create in Global.asax a session variable - UrlRoot - that I can
> reference anywhere in the application that holds the virtual root whether
> the app is running on my dev machine, a local testing server, or the
> remote production server like so ...
>
> <a href= UrlRoot & "/Common/ListView.aspx"
>
> I have tried:
> Session.Add("URL_Root", "http://" & Request.Url.Host)
> Session.Add("URL_Root", "http://" &
> HttpContext.Current.Request.ApplicationPath)
> Session.Add("URL_Root", VirtualPathUtility.ToAppRelative("/"))
>
> No matter what method I use or where I run the app the link dynamically
> created in the Excel file seems to be returning:
>
> http://localhost/Common/ListView.aspx
> rather than
> http://www.prodserv.com/Common/ListView.aspx
>
> Can anyone lend assistance? I need the URL_Root to return the root domain
> of what the User would type into the browser to get to the correct page.
> Thanks...
>



 
Reply With Quote
 
John Kotuby
Guest
Posts: n/a
 
      05-23-2007
Thanks SAL,

I think that Server.MapPath will actually give me a machine path like
C:\INETPUB\WWW\COMMON\ListView.apsx.
It's usually used to get absolute path references for opening files with the
File System Object and such.

"SAL" <SAL_@NoNo.com> wrote in message
news:...
> Have you tried:
> Session.Add("URL_Root", Server.MapPath(""))
>
> Not sure if you can use it but maybe...
>
> S
>
> "John Kotuby" <> wrote in message
> news:...
>> Hi all..
>>
>> In a VS2005 ASP.NET 2.0 website application I am using a regular HTML
>> anchor (actually a number of them) in a page that produces Excel output
>> because a server control is really not needed here. I am using a relative
>> path in the anchor such as:
>> <a href= "/Common/ListView.aspx"
>>
>> My understanding is that I cannot use the syntax:
>>
>> <a href="~/Common/ListView.aspx"
>>
>> ...if I am not declaring a Server control. Maybe I am wrong there... but
>> anyway...
>>
>> I want to create in Global.asax a session variable - UrlRoot - that I
>> can reference anywhere in the application that holds the virtual root
>> whether the app is running on my dev machine, a local testing server, or
>> the remote production server like so ...
>>
>> <a href= UrlRoot & "/Common/ListView.aspx"
>>
>> I have tried:
>> Session.Add("URL_Root", "http://" & Request.Url.Host)
>> Session.Add("URL_Root", "http://" &
>> HttpContext.Current.Request.ApplicationPath)
>> Session.Add("URL_Root", VirtualPathUtility.ToAppRelative("/"))
>>
>> No matter what method I use or where I run the app the link dynamically
>> created in the Excel file seems to be returning:
>>
>> http://localhost/Common/ListView.aspx
>> rather than
>> http://www.prodserv.com/Common/ListView.aspx
>>
>> Can anyone lend assistance? I need the URL_Root to return the root domain
>> of what the User would type into the browser to get to the correct page.
>> Thanks...
>>

>
>



 
Reply With Quote
 
Steve C. Orr [MCSD, MVP, CSM, ASP Insider]
Guest
Posts: n/a
 
      05-23-2007
Try adding the runat='server' attribute to your anchor tag. If I remember
right that will translate the tilde(~) for you...
<a href="~/Common/ListView.aspx" runat='"server">Click me</a>

--
I hope this helps,
Steve C. Orr,
MCSD, MVP, CSM, ASPInsider
http://SteveOrr.net


"John Kotuby" <> wrote in message
news:...
> Hi all..
>
> In a VS2005 ASP.NET 2.0 website application I am using a regular HTML
> anchor (actually a number of them) in a page that produces Excel output
> because a server control is really not needed here. I am using a relative
> path in the anchor such as:
> <a href= "/Common/ListView.aspx"
>
> My understanding is that I cannot use the syntax:
>
> <a href="~/Common/ListView.aspx"
>
> ...if I am not declaring a Server control. Maybe I am wrong there... but
> anyway...
>
> I want to create in Global.asax a session variable - UrlRoot - that I can
> reference anywhere in the application that holds the virtual root whether
> the app is running on my dev machine, a local testing server, or the
> remote production server like so ...
>
> <a href= UrlRoot & "/Common/ListView.aspx"
>
> I have tried:
> Session.Add("URL_Root", "http://" & Request.Url.Host)
> Session.Add("URL_Root", "http://" &
> HttpContext.Current.Request.ApplicationPath)
> Session.Add("URL_Root", VirtualPathUtility.ToAppRelative("/"))
>
> No matter what method I use or where I run the app the link dynamically
> created in the Excel file seems to be returning:
>
> http://localhost/Common/ListView.aspx
> rather than
> http://www.prodserv.com/Common/ListView.aspx
>
> Can anyone lend assistance? I need the URL_Root to return the root domain
> of what the User would type into the browser to get to the correct page.
> Thanks...
>


 
Reply With Quote
 
SAL
Guest
Posts: n/a
 
      05-24-2007
Right you are John. If you don't want to make these server controls, maybe
you could parse the path to get what you need from it???

S

"John Kotuby" <> wrote in message
news:...
> Thanks SAL,
>
> I think that Server.MapPath will actually give me a machine path like
> C:\INETPUB\WWW\COMMON\ListView.apsx.
> It's usually used to get absolute path references for opening files with
> the File System Object and such.
>
> "SAL" <SAL_@NoNo.com> wrote in message
> news:...
>> Have you tried:
>> Session.Add("URL_Root", Server.MapPath(""))
>>
>> Not sure if you can use it but maybe...
>>
>> S
>>
>> "John Kotuby" <> wrote in message
>> news:...
>>> Hi all..
>>>
>>> In a VS2005 ASP.NET 2.0 website application I am using a regular HTML
>>> anchor (actually a number of them) in a page that produces Excel output
>>> because a server control is really not needed here. I am using a
>>> relative path in the anchor such as:
>>> <a href= "/Common/ListView.aspx"
>>>
>>> My understanding is that I cannot use the syntax:
>>>
>>> <a href="~/Common/ListView.aspx"
>>>
>>> ...if I am not declaring a Server control. Maybe I am wrong there... but
>>> anyway...
>>>
>>> I want to create in Global.asax a session variable - UrlRoot - that I
>>> can reference anywhere in the application that holds the virtual root
>>> whether the app is running on my dev machine, a local testing server, or
>>> the remote production server like so ...
>>>
>>> <a href= UrlRoot & "/Common/ListView.aspx"
>>>
>>> I have tried:
>>> Session.Add("URL_Root", "http://" & Request.Url.Host)
>>> Session.Add("URL_Root", "http://" &
>>> HttpContext.Current.Request.ApplicationPath)
>>> Session.Add("URL_Root", VirtualPathUtility.ToAppRelative("/"))
>>>
>>> No matter what method I use or where I run the app the link dynamically
>>> created in the Excel file seems to be returning:
>>>
>>> http://localhost/Common/ListView.aspx
>>> rather than
>>> http://www.prodserv.com/Common/ListView.aspx
>>>
>>> Can anyone lend assistance? I need the URL_Root to return the root
>>> domain of what the User would type into the browser to get to the
>>> correct page.
>>> Thanks...
>>>

>>
>>

>
>



 
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
How to remove virtual path from root url of dev web server? Steve Franks ASP .Net 20 12-07-2009 05:19 AM
physical path to virtual path under virtual directory =?Utf-8?B?SmVmZiBCZWVt?= ASP .Net 4 08-01-2007 02:59 PM
How can I run the "Development server" w/o a virtual path? (root) cmay ASP .Net 2 04-12-2006 07:53 PM
Help: root path reference hb ASP .Net 2 01-28-2005 05:25 PM
Virtual Path and physical root ASP General 4 08-02-2004 08:31 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57