Denying unauthenticated access to a .txt file

  • Thread starter Thread starter Penguini
  • Start date Start date
P

Penguini

I have a website using c# and .Net 2. I have two .txt files placed in
a subfolder that I need to protect. The site is protected by Forms
Authentication, and the files are inside a folder that is set to deny
anonymous access. When run locally on my machine, this all works fine;
typing the full path of one of the text files redirects the user to
the login screen as expected. However, when I publish the website to a
webserver, typing the full path simply opens the text file in an IE
window - no redirection takes place. How can I stop this? Any help
greatfully received!
 
You would need to map the ".txt" extension to be handled through ASP.NET in
order for this to work. Alternatively, you could store the files in a folder
that is outside of the IIS web application, and use Response.WriteFile method
to serve them.

--Peter
"Inside every large program, there is a small program trying to get out."http://www.eggheadcafe.comhttp://petesbloggerama.blogspot.comhttp://www.blogmetafinder.com





- Show quoted text -

Thanks, I have added the .txt extension to be handled by ASP.NET, as
having the files in another folder is not an option in this case.
Problem sorted, thanks again!
 
Back
Top