Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / December 2007

Tip: Looking for answers? Try searching our database.

Denying unauthenticated access to a .txt file

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Penguini - 03 Dec 2007 10:28 GMT
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!
Peter Bromberg [C# MVP] - 03 Dec 2007 14:29 GMT
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.com
http://petesbloggerama.blogspot.com
http://www.blogmetafinder.com

> 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
[quoted text clipped - 5 lines]
> window - no redirection takes place. How can I stop this? Any help
> greatfully received!
Penguini - 03 Dec 2007 16:53 GMT
On 3 Dec, 14:29, Peter Bromberg [C# MVP]
<pbromb...@yahoo.NoSpamMaam.com> wrote:
> 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
[quoted text clipped - 15 lines]
>
> - 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!

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.