Deny access to a directory with web.config

M

Matt

Hello,
I'm working on a portal based on IBuySpy, where the main page is
desktopdefault.aspx and all content is stored in
www.domain.com/content/html/nnn
or
www.domain.com/content/images/nnn
and injected in the desktopdefault.aspx page.

How can I prevent users doing www.domain.com/content/images/test.jpg
and getting the image (or the html file, or whatever inside the
content directory?)
It doesn't matter if the user is authenticated or not, I just want
obly the webapplication to be able to load and display the files
inside the /content directory.

Can I do this just manipulating the web.config, without changing
directory permissions on the webserver?


Thanks!
 
M

Matt

Good suggestion, but is there a way to control access to that
directory with the web.config?

Thanks.
 
J

Juan T. Llibre

web.config :

<?xml version="1.0" encoding="utf-8" ?>
<configuration>

<system.web>
<authorization>
<allow users="ASPNET's account name"/>
<deny users="*"/>
</authorization>

</system.web>
</configuration>
 
B

Brock Allen

Good suggestion, but is there a way to control access to that
directory with the web.config?

Not if IIS is serving up the files, as the request never makes it to ASP.NET.
 
J

Juan T. Llibre

I think that adding the specific file types to the files managed
by ASP.NET will turn the trick if you implement forms-based
authentication to the directory.
 
B

Brock Allen

I think that adding the specific file types to the files managed by
ASP.NET will turn the trick if you implement forms-based
authentication to the directory.

Yep, that will work.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,776
Messages
2,569,602
Members
45,185
Latest member
GluceaReviews

Latest Threads

Top