How to hide "localhost"

  • Thread starter Thread starter Greg Cyrus
  • Start date Start date
"localhost" is the default Domain name of the local machine. It maps to IP
Address "127.0.0.1" (local loopback). Therefore, on any machine which uses
"localhost" in a URL, a redirect will always go to their local web server
(if any) or throw an exception. For this reason, you should NEVER use the
string "localhost" in your app, unless you plan to run it only locally.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living
 
Response.Redirect("http://localhost/WebApplication3/frmDefault.aspx")
wont work, if you try to access your site from some other machine. You have
to use one of the HttpRequest properties (such as Path, Or Url, Or some of
the ServerVariables item) to construct your HTTP path.

Something like:
Response.Redirect( Request.Url.Scheme + "://" + Request.Url.Host +
Requestr.ApplicationPath + "/frmDefault.aspx");
 
If you are doing the Reponse.Redirect FROM WebApplication3 virtual directory
then just do:

Response.Redirect("frmDefault.aspx")

or

Response.Redirect("~/frmDefault.aspx") if you were calling this from within
a subdirectory.

"~" resolves to http://localhost/WebApplication3/ (in your case)

You should never hardcode server names, etc.

Prefixing your web pages with "frm" seems kinda strange to me...

Greg
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top