Preventing website access to non-logged in users

Last post 07-06-2009 10:27 AM by fyffemark. 3 replies.

Sort Posts:

  • Preventing website access to non-logged in users

    07-03-2009, 11:03 AM
    • Member
      2 point Member
    • fyffemark
    • Member since 04-09-2008, 10:04 AM
    • Posts 39

    I am having trouble configuring my web app to prevent users who have not logged in from accessing the website.  I have my web.config authentication mode set to "Forms" but when I attempt to access another page by simply typing url the page does not redirect to login page like I am expecting please inform as to what I am doing wrong; here is my code from web.config:

    <authentication mode="Forms">

          <forms loginUrl="Login.aspx" protection="All" timeout="30" />

    </authentication>

    <authorization>

          <allow users="*" />

    </authorization>

  • Re: Preventing website access to non-logged in users

    07-03-2009, 6:20 PM
    • Member
      211 point Member
    • pryanjr
    • Member since 04-19-2009, 6:51 PM
    • Posts 99

    Right under <allow user="*" /> add <deny users="?" />

  • Re: Preventing website access to non-logged in users

    07-04-2009, 7:58 AM
    • All-Star
      60,891 point All-Star
    • anas
    • Member since 09-21-2006, 4:31 AM
    • Palestinian Territory, Occupied
    • Posts 6,865
    • Moderator

    fyffemark:

    <authorization>

          <allow users="*" />


    </authorization>

    Instead , it must be :

    <authorization>
          <deny users="?" />
    </authorization>


    Regards,

    Anas Ghanem | Blog

  • Re: Preventing website access to non-logged in users

    07-06-2009, 10:27 AM
    • Member
      2 point Member
    • fyffemark
    • Member since 04-09-2008, 10:04 AM
    • Posts 39

     Appreciate the suggestions but nothing seems to be working let me spell out in more detail what I have done so far:

    First of all I have two web.config files one at the level of the log in page and one which is with the rest of the website in a Secure folder.   The web.config which is at the level of the login table looks like this initially:

    ...<!-- Login Level -->

     <authentication mode="Forms">
          <forms loginUrl="Login.aspx" protection="All" timeout="30" path="/"/>
        </authentication>

        <authorization>
          <allow users="*"/>
         </authorization>

    ...

    Web.config at the level of the Secure folder looks like this initially:

    ...

    <authorization>
            <deny users="?" />
    </authorization>

    ... 

    These settings don't allow anyone in whether properly logged in or typing the URL to the secured page everyone is redirected to login.

    Then I tried this:

    ...<!-- Login Level -->

     <authentication mode="Forms">
          <forms loginUrl="Login.aspx" protection="All" timeout="30" path="/"/>
        </authentication>

        <authorization>
          <allow users="*"/>
          <deny users="?" />
        </authorization>

    ...

    ...<!--Secure level -->

    <authorization>
            <deny users="?" />
    </authorization>

    ... 

    Same result as previous no one allowed in.  Next try looked like this:

    ...<!-- Login Level -->

     <authentication mode="Forms">
          <forms loginUrl="Login.aspx" protection="All" timeout="30" path="/"/>
        </authentication>

        <authorization>
             <!--<allow users="*"/>-->

             <deny users="?" />
        </authorization>

    ...

    ...<!--Secure level -->

    <authorization>
            <deny users="?" />
    </authorization>

    Same result -- next try looked like this:

    ...<!-- Login Level -->

     <authentication mode="Forms">
          <forms loginUrl="Login.aspx" protection="All" timeout="30" path="/"/>
        </authentication>

        <authorization>
             <allow users="*"/>

             <deny users="?" />
        </authorization>

    ...

    ...<!--Secure level -->

    <authorization>
            <allow users="*"/>

           <deny users="?" />
    </authorization>

    ...

    This setting allows everyone entry even non-logged in users.  My last try looked like this:

    ...<!-- Login Level -->

     <authentication mode="Forms">
          <forms loginUrl="Login.aspx" protection="All" timeout="30" path="/"/>
        </authentication>

        <authorization>
             <allow users="*"/>

             <deny users="?" />
        </authorization>

    ...

    ...<!--Secure level -->

    <authorization>
           <!--<allow users="*"/>-->

           <deny users="?" />
    </authorization>

    ...

    This setting denied all users?  Please help very confused at this point.

Page 1 of 1 (4 items)