简体   繁体   中英

How to redirect to page in the root directory from any internal page in asp.net

If I have page located for example in

http://hostname.com/website_folder/page1.aspx

and from page in internal folder, I want to redirect to the above page For example from these pages:

http://hostname.com/website_folder/folder1/folder2/page2.aspx

or

http://hostname.com/website_folder/folder1/folder2/folder3/page2.aspx

Try to use Response.Redirect(your url); in your code behind page.
if you like to know more read here http://support.microsoft.com/kb/307903

I assume whenever the request comes for the below urls

http://hostname.com/website_folder/folder1/folder2/page2.aspx http://hostname.com/website_folder/folder1/folder2/folder3/page2.aspx

you want to perform a permanent redirect to http://hostname.com/website_folder/page1.aspx .

This can be achieved by URL Mapping/Rewrite

There are several approaches explained by Scott Guthrie and also check How to specify url mappings in ASP.NET 4.0 when parameters are involved?

Hope this would help you

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM