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

Tags:

asp net image uploadAsp.net Convert String To ImageAsp.net Convert Image To Base64Jquery image click eventSecure ImageASP net Write Text On Image C#.net and Vb.net programHow to check image is loaded using JQueryJQuery how to change background imageDiv Background ImageLoad images fasterDo you want to view only the webpage content that was delivered securely

Author

My name is Satalaj, but people call me Sat. Here is my homepage: . I live in Pune, PN and work as a Software Engineer. I'm former MVP in ASP.net year 2010.
Disclaimer: Views or opinion expressed here are my personal research and it has nothing to do with my employer. You are free to use the code, ideas/hints in your projects. However, you should not copy and paste my original content to other web sites. Feel free to copy or extend the code.
If you want to fight with me, this website is not for you.
 

I'm Satalaj.