Ronnie Kapoor

Ronnie Kapoor

  • NA
  • 2
  • 913

Images not authorized in MVC application?

May 8 2018 3:34 AM
I have a requirement to authorize static resources present in my application so that only logged in users can access those including images.
 
I have form authentication enabled in my application and i am using authorization attribute in web.config and localized web.config in folders for which i want to provide access to anonymous users.
 
But the images are not secured and getting accessed even when the user is not logged in. Rest of the resources such as css and js are secured.
 
I am using below code in global web.config
  1. <authentication mode="Forms">  
  2. <forms loginUrl="<URL>" timeout="10" slidingExpiration="true" />  
  3. </authentication>  
  4. <authorization>  
  5. <deny users="?" />  
  6. </authorization>  
and in localized web.config
  1. <?xml version="1.0" encoding="utf-8"?> <configuration> <location path="Content/Custom/login.scss"> <system.web> <authorization> <allow users="*" /> </authorization> </system.web> </location> <location path="Content/Images/CSSbundle"> <system.web> <authorization> <allow users="*" /> </authorization> </system.web> </location> <location path="Content/images"> <system.web> <authorization> <deny users="?"/> </authorization> </system.web> </location> </configuration>
where am i missing something ?

Answers (1)