Using Response.Redirect() to a relative path.

Posted by Bryan on Stack Overflow See other posts from Stack Overflow or by Bryan
Published on 2010-06-02T18:57:21Z Indexed on 2010/06/02 19:04 UTC
Read the original article Hit count: 274

Filed under:

I'm working with ASP.net. My website is hosted within a subfolder test under the IIS root directory. So the url of default.aspx is http://localhost/test/Default.aspx. From default.aspx, I want to use Reponse.Redirect() with a relative path to redirect to another url within the same web site, http://localhost/test/whatever.

I tried

Response.Redirect("/hello");

and

Response.Redirect("~/hello");

Both of them redirect to http://localhost/whatever. Note that the Redirect method use http://localhost instead of http://localhost/test/ as the base url.

Any ideas?

Thanks.

© Stack Overflow or respective owner

Related posts about ASP.NET