467,075 Members | 932 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

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

How to hide "localhost"

Hi,

in a Page_Load I use:
Response.Redirect("http://localhost/WebApplication3/frmDefault.aspx")

Now the IExplorer shows "http://localhost/WebApplication3/frmKopf.aspx" in
the adress-field. Is the name "localhost" shown in my ieplorer only - if not
how can I rename it (or shouldn't I).

Greg.

Nov 18 '05 #1
  • viewed: 3291
Share:
4 Replies
Response.Redirect("/WebApplication3/frmDefault.aspx")

"Greg Cyrus" <no****@muelltonne.de> wrote in message
news:cj*************@news.t-online.com...
Hi,

in a Page_Load I use:
Response.Redirect("http://localhost/WebApplication3/frmDefault.aspx")

Now the IExplorer shows "http://localhost/WebApplication3/frmKopf.aspx" in the adress-field. Is the name "localhost" shown in my ieplorer only - if not how can I rename it (or shouldn't I).

Greg.

Nov 18 '05 #2
> 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");
--
Girish Bharadwaj
http://msmvps.com/gbvb
"Greg Cyrus" <no****@muelltonne.de> wrote in message
news:cj*************@news.t-online.com...
Hi,

in a Page_Load I use:
Response.Redirect("http://localhost/WebApplication3/frmDefault.aspx")

Now the IExplorer shows "http://localhost/WebApplication3/frmKopf.aspx" in the adress-field. Is the name "localhost" shown in my ieplorer only - if not how can I rename it (or shouldn't I).

Greg.

Nov 18 '05 #3
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

"Greg Cyrus" <no****@muelltonne.de> wrote in message
news:cj*************@news.t-online.com...
Hi,

in a Page_Load I use:
Response.Redirect("http://localhost/WebApplication3/frmDefault.aspx")

Now the IExplorer shows "http://localhost/WebApplication3/frmKopf.aspx"
in the adress-field. Is the name "localhost" shown in my ieplorer only -
if not how can I rename it (or shouldn't I).

Greg.

Nov 18 '05 #4
"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

"Greg Cyrus" <no****@muelltonne.de> wrote in message
news:cj*************@news.t-online.com...
Hi,

in a Page_Load I use:
Response.Redirect("http://localhost/WebApplication3/frmDefault.aspx")

Now the IExplorer shows "http://localhost/WebApplication3/frmKopf.aspx" in the adress-field. Is the name "localhost" shown in my ieplorer only - if not how can I rename it (or shouldn't I).

Greg.

Nov 18 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Chris | last post: by
12 posts views Thread by Jonathan Wood | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.