views:

323

answers:

1

In my asp.net web application, I have a folder in which I have a few html and jpeg files. some of these files do not need a user to login while the others do. How do I exclude the files that are free for view to be displayed without logging in while still maintaining the user to login for viewing other files in the same folder using just the config file. I wasnt able to find something relevant in the config file or maybe I overlooked it. If anyone knows please reply.

Thanks.

+1  A: 

I've tried to answer this as well as I can but the sentence:

How do I exclude the files that are free for view to be displayed without logging in while still maintaining the user to login for viewing other files in the same folder using just the config file.

..is a bit confusing!

The files that need to be authenticated are the ones that are handled by the asp.net handler such as .aspx files. jpegs and other static files bypass this so can be viewed without authentication. The handler aspnet_isapi only handles certain files but you can configure it to handle more file extensions (or all files) by configuring extension mappings in IIS.

Personally, I would put all files I wanted to be unprotected in a folder with permissions to allow anyone to view that folder, set the aspnet_isapi handler to handle all files and then protect your other folders according to your application's needs.

Depending on what you want to do (as your question isn't that clear), you may or may not be able to achieve what you want just from the config file but hopefully this answer will give you the information you need to make your own conclusions on that.

Neil Trodden
thanks Neil, what I meant was in my website I have an images folder. All images there need to be protected except the ones I need to show on the login page. Currently even the images on my login page cant be seen because the application is waiting for me to login to show it to the user.
Is there a way I can tell the application to exclude certain files, just by making the relevant entries in the config file.? if yes what would those entries be?
You can if the files are handled by ASP.NET - i.e. .aspx pages - the JPEG/HTML files are not served by ASP.NET but directly from IIS, and so they won't be locked down. Your best bet would be to serve them through an .ashx handler, or on/in an .aspx page - this would give you greater control. http://msdn.microsoft.com/en-us/library/8d82143t.aspx has examples of securing files and directories through the config.
Zhaph - Ben Duguid
Thanks Zhaph :)