Secure Image

Secure Image  In this post we will secure image /files  from being accessed by anonymous users.
In ASP.net 2.0 web.config  we will add 6 lines of code.
 Scenario: I have stored all images in images folder found at the root. I will add below web.config file to my images folder.
It will let the users who are in role Editor of  site to access and it will ban anonymous users . 
 
 <?xml version=
"1.0"?> 
    
<configuration>
    <appSettings
/>
    <connectionStrings
/>
      <system.web
>
            <authorization
>
                  <deny users=
"?"/>
                  <allow roles="Editor"/>
 
          </authorization>
      </system.web
>
  
</configuration> 

Eventually, whatever you store inside the images folder will not be accesible to users who are not in role Editor.


To see how we can use asp.net membershipprovider based model please refer http://revenmerchantservices.com/page/ASpnet-20-step-by-step-Membership-Provider-.aspx

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5