467,116 Members | 1,142 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,116 developers. It's quick & easy.

How to Remove "http://localhost" from my URLs

I am testing a web app that links to user defined URLs. I want the link
to be the exact text the user provided but I can't seem to get rid of
the "http://localhost" prefix in the link. Note that I am user defined
email addresses for "mailto:" links and the same problem occurs.

Is this something that will be removed when the site is published?

All help is appreciated,
Lee

Feb 7 '06 #1
  • viewed: 4161
Share:
3 Replies
Does this prefix appear in the generated HTML code of the web page? Or is it
the browser who is too smart?

"Lee Roth" <le******@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
I am testing a web app that links to user defined URLs. I want the link
to be the exact text the user provided but I can't seem to get rid of
the "http://localhost" prefix in the link. Note that I am user defined
email addresses for "mailto:" links and the same problem occurs.

Is this something that will be removed when the site is published?

All help is appreciated,
Lee

Feb 8 '06 #2
It's the browser. The HTML in the code is basic. For example:

string userURL = userURLTextBox.Text; // say the user inputs
"www.google.com"
string htmlCode = "<a href = " + userURL + "> User Link </a>";

But instead of just google the link becomes
"http://localhost/www.google.com" which is a page it obviously can't
find.

So how do I use the code to make sure this doesn't happen to the end
users?

Thanks,
Lee

Feb 8 '06 #3
Hey Lee,

You can automatically prefix any user input with http:// if the input does
not start with any protocol specification (bear in mind that these are not
only http:// or https://, can also be ftp:// or even telnet://)

"Lee Roth" <le******@gmail.com> wrote in message
news:11*********************@g14g2000cwa.googlegro ups.com...
It's the browser. The HTML in the code is basic. For example:

string userURL = userURLTextBox.Text; // say the user inputs
"www.google.com"
string htmlCode = "<a href = " + userURL + "> User Link </a>";

But instead of just google the link becomes
"http://localhost/www.google.com" which is a page it obviously can't
find.

So how do I use the code to make sure this doesn't happen to the end
users?

Thanks,
Lee

Feb 9 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

24 posts views Thread by sinister | last post: by
3 posts views Thread by John Nagle | last post: by
reply views Thread by almurph@altavista.com | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.