Click here to Skip to main content
16,018,529 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have one website, i have used login control, in web.config file followig code snipet is there.
XML
<location path="data"></location>
    <system.web>.....

XML
<authentication mode="Forms" >
        <forms defaultUrl="Default.aspx" protection="All" cookieless="UseCookies" name="webaite1" loginUrl="~/login.aspx" path="/"></forms>
      </authentication>
        <compilation debug="false" strict="false" explicit="true" targetFramework="4.0" />
    </system.web>

I have one folder name data, within which i have a marks.aspx and a web.config file. This web.config file has code snipet as follows:
XML
<configuration>
  <location path="data" ></location>
    <system.web>
      <authorization >
        <deny users="five"/>
      </authorization>
    </system.web>
</configuration>

You can see user five is denied to see this page.
Problem is that if any one is accessing this mark.aspx page directly then page is accessed without letting the user to login.
I want that if some one trying to access secure page directly then also he should login, login.aspx should appears first.
Posted

1 solution

do as below, it will deny anonymous users access to the site
HTML
<configuration>
   <system.web>
      <forms defaulturl="Default.aspx" protection="All" cookieless="UseCookies" name="webaite1" loginurl="~/login.aspx" path="/"></forms>
      <authorization>
         <deny users="?" />
      </authorization>
      <compilation debug="false" strict="false" explicit="true" targetframework="4.0" />
   </system.web>
</configuration>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900