Protecting my CSS using a location tag in web.config

G

GD

I'd like to prevent users from downloading my CSS file. I thought about
putting a web.config file inside my CSS directory as follows:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<authorization>
<deny users="*"/>
</authorization>
</system.web>
</configuration>

However, if I browse directly to http://mysite/css/style.css, I can
still download the file.

Am I setting up the web.config correctly? When set up correctly, will
this prevent my aspx pages from accessing my style sheet?

Thanks!
 
G

Guest

GD,
If somebody really wants your css file, they are just going to get it out of
their browser's cache. There is css all over the place. I just don't think
its a valid concern.
Peter
 
D

darrel

I'd like to prevent users from downloading my CSS file.

That defeats the purpose of using a CSS file. By it's very nature it HAS to
be downloaded for the browser to use it.
Am I setting up the web.config correctly? When set up correctly, will
this prevent my aspx pages from accessing my style sheet?

web.config only applies to .aspx pages. .css is handled directly by IIS.

You could, if you wanted to, just rename your css page as aspx and be sure
to send the proper header.

However, it will STILL be downloaded by the browser, so it doesn't make that
much sense to bother with this. How proprietary is your CSS file anyways?

-Darrel
 
G

GD

Thanks guys,
It's a client request ... I agree that it's pretty lame ... Seems like
more effort than is worth
 
D

darrel

It's a client request ... I agree that it's pretty lame ... Seems like
more effort than is worth

Definitely. This sounds like a 'client education' solution. ;o)

-Darrel
 

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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top