How to use Response.Redirect from sub folder to root in ASP.NET, Prevent user from viewing directory listing

SHAFEES PS picture SHAFEES PS · Sep 17, 2014 · Viewed 8.5k times · Source

I have two pages in my root directory
1. Default.aspx (login page)
2. Home.aspx

and also one folder Attachments where i store the attachment files, from Home.aspx user can download the attachments. In order to prevent user from viewing Directory listing i add one more aspx page in this directory.
1. Root/Attachments/Default.aspx

now i want to Redirect the user to login page (Root/Default.aspx) from Root/Attachments/Default.aspx.

How this could be done.

Answer

jrummell picture jrummell · Sep 17, 2014

There are a couple things you can do:

If you do the second option, you could then change your redirect to Response.Redirect("~/").