Thursday, September 11, 2008

Password Protecting Single File

Password protecting comes under the section of ASP Membership & Security. ASP.Membership & Security can be employed to protect a file-access from an unauthorized user. By default, we can protect aspx pages only. However, we can add additional file-extension using the IIS Configuration Manager.

Below code segment protects secret.aspx from unauthorized uesrs. A '?' denotes anonymous/unauthorized users; whereas a '*' represents all user.



web.config

<configuration>
   <location path="Secret.aspx">
      <system.web>
         <authentication mode=”Forms” />
         <authorization>
            <deny users="?"/>
         </authorization>
      </system.web>
  </location>
</configuration>



No comments:

 
Best viewed in Internet Explorer 8.