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("/whatever");
and
Response.Redirect("~/whatever");
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.
redirect() The redirect() method of the Response interface returns a Response resulting in a redirect to the specified URL.
For instance, instead of a "form" button that causes a postback and redirect, you could use a LinkButton that will behave like a hyperlink, allowing the browser to request the new page directly.
Response. Redirect("Default. aspx", true) means current page execution is terminated and page is redirected to the default.
Redirect(String) Redirects a request to a new URL and specifies the new URL. Redirect(String, Boolean) Redirects a client to a new URL. Specifies the new URL and whether execution of the current page should terminate.
Try:
Response.Redirect("hello");
also
Response.Redirect("./hello");
Enjoy!
Sorry if I'm over-simplifying or misunderstanding your question, but have you simply tried:
Response.Redirect("hello");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With