|
-
Mar 6th, 2008, 10:08 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] [2008] Link Format
I'm developing websites that are primarily used on a local intranet, but i want to be sure that if someone vpn's into the network that all of my links still work.
For example i have a directory page that has links with the format http://<server name>/<application name> and this works fine for anyone already on our local net, but if i want to connect through a vpn connection the address becomes http://<server name>.<domain name>.com/<application name>. So the previous links on the directory page will not work.
Is it just best practice to include the domain name? Or is there a way to dynamically make the links compliant with how the user is accessing the site?
~S_M
Using VB6 or VB.net 2008 with .net 3.5
"Life... death... either way I'll be confined to a small cubicle!" - Hermes Conrad
-
Mar 6th, 2008, 11:29 AM
#2
Re: [2008] Link Format
Don't rely on the http://hostname/ when creating links. Create them in such a way that they can be moved from http://server1/xyz to http://www.blah.com/ or http://sub.domain.com/sub/folder/anywhere. In other words, the application's 'context' of links is limited to the application folder and subfolders.
You have the ~ (tilde) which allows you to specify links without need for a hostname.
Hyperlink1.NavigateUrl = "~/subfolder/image.jpg"
The ~ resolves to http://whatever.domain.com and so on.
-
Mar 6th, 2008, 11:47 AM
#3
Thread Starter
Fanatic Member
Re: [2008] Link Format
I should have been doing this all along.
One other question, what about linking across subfolders. In the example above my directory page actually sits in a subfolder that is on the same level as the applications it links to, so lets say i want to link from http://hostname/directory to http://hostname/app1. If i use your example and just try to have the link set as Hyperlink1.NavigateUrl = "~/app1" the link naturally tries to take me to http://hostname/directory/app1 which of course doesn't exist.
Is this a bad file structure or am i missing something with how to use the ~?
Using VB6 or VB.net 2008 with .net 3.5
"Life... death... either way I'll be confined to a small cubicle!" - Hermes Conrad
-
Mar 6th, 2008, 11:50 AM
#4
Re: [2008] Link Format
That's a different case - you're trying to link across different different 'applications' or 'virtual directories' there, aren't you?
I didn't know this from your first post. If /directory is external to your application /app1, then yeah, you can't use the tilde. Instead, you then rely on clever string manipulations.
Either say
/directory/...
or use this:
Request.Url.Host
to concatenate your path to the external directory.
-
Mar 6th, 2008, 12:10 PM
#5
Thread Starter
Fanatic Member
Re: [2008] Link Format
 Originally Posted by mendhak
That's a different case - you're trying to link across different different 'applications' or 'virtual directories' there, aren't you?
I didn't know this from your first post. If /directory is external to your application /app1, then yeah, you can't use the tilde. Instead, you then rely on clever string manipulations.
Either say
/directory/...
or use this:
Request.Url.Host
to concatenate your path to the external directory.
Yeah I'm linking between two virtual directories. In the first post i was interested in the conventional way that links are handled and in the second i was interested in this specific case. So consider two questions answered. 
Thanks.
S_M
Using VB6 or VB.net 2008 with .net 3.5
"Life... death... either way I'll be confined to a small cubicle!" - Hermes Conrad
-
Mar 6th, 2008, 12:43 PM
#6
Re: [RESOLVED] [2008] Link Format
You're twice as welcome.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|