locked
why does Identity.IsAuthenticated always equal true? RRS feed

  • Question

  • User-1938039701 posted

     Hi

    I have this in my page load. I am refactoring my site so I have not included even a login button yet but I am wondering why this keeps coming up true.

     

        Guid ProviderUserKey;
    protected void Page_Load(object sender, EventArgs e)
    {
    if (User.Identity.IsAuthenticated == true)
    {

    MembershipUser mu = Membership.GetUser();
    ProviderUserKey = (Guid)mu.ProviderUserKey;

    }
    }
    like how is the User Identity authenticated? like I thought this would only happen if they where logged in.
    In my Guid it has this in it 00000000-0000-0000-0000-000000000000 by default so I don't know if that has anything to do with it. 
     

     

     

    Friday, February 22, 2008 1:35 AM

Answers

  • User-186742165 posted

    Hi

    You should use   <authentication mode="Forms" /> since windows authentication mode will use your windows login credential, Therefore user is not anonymous.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, February 27, 2008 3:02 AM
  • User224411821 posted

    Becuase you have the <authentication mode="Winows" /> the application is taking your windows account and becuase you are authenticated on windows you are automatically authenticated on the .net application.

    The change this change to <authentication mode="Forms" />.

    Hope that helps 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, February 27, 2008 4:16 AM

All replies

  • User960609757 posted

     

    hi,

    check your Authentication and authorization tag in your  web.config file

     

    Friday, February 22, 2008 3:34 AM
  • User2141573534 posted
    Do you have following tag on web.config file? 
    <!-- Web.config file -->
    <configuration>
    <system.web>
    <authentication mode="Windows" />
    <authorization>
    <allow users="domain1\user, domain2\user2, domain1\user3" />
    <deny users="*" />
    </authorization>
    </system.web>
    </configuration>

     

    Friday, February 22, 2008 4:11 AM
  • User-1938039701 posted

     

    hi,

    check your Authentication and authorization tag in your  web.config file

     

     

    All I could find is this:

    <authentication mode="Windows"/>

    and


    <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
    but no Authentication....Should I have both in there?
    So I am guessing why it is working is because its using windows authentication? So I got to change that but not sure to which one though.
    Also if I would have not asked about this and posted it online would this have been an issue(ie would it keep authentication to windows) or would I be scratching my head wondering why it is not working? 
     
     
    Friday, February 22, 2008 4:15 AM
  • User-1938039701 posted

    Do you have following tag on web.config file? 
    <!-- Web.config file -->
    <configuration>
    <system.web>
    <authentication mode="Windows" />
    <authorization>
    <allow users="domain1\user, domain2\user2, domain1\user3" />
    <deny users="*" />
    </authorization>
    </system.web>
    </configuration>

     

     

    only have 

    <authentication mode="Windows" />
    not the rest. 
    Saturday, February 23, 2008 4:40 PM
  • User-186742165 posted

    Hi

    You should use   <authentication mode="Forms" /> since windows authentication mode will use your windows login credential, Therefore user is not anonymous.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, February 27, 2008 3:02 AM
  • User224411821 posted

    Becuase you have the <authentication mode="Winows" /> the application is taking your windows account and becuase you are authenticated on windows you are automatically authenticated on the .net application.

    The change this change to <authentication mode="Forms" />.

    Hope that helps 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, February 27, 2008 4:16 AM
  • User-1938039701 posted

    Becuase you have the <authentication mode="Winows" /> the application is taking your windows account and becuase you are authenticated on windows you are automatically authenticated on the .net application.

    The change this change to <authentication mode="Forms" />.

    Hope that helps 

     

    Ok I changed it thanks. 

    Wednesday, February 27, 2008 3:49 PM