Authentication for page fails

Discussion in 'Site Programming, Development and Design' started by ginger, May 15, 2013.

  1. Hey Guys,

    I wanted users to login before they access a particular page but it seems it's not hitting the login page. It works fine on my local machine but after deploying it on server it behaves a little strange.

    This is what I have:

    <authentication mode="Forms">
    <forms defaultUrl="personality/personalitytest.htm" loginUrl="personality/login.aspx">
    </forms>
    </authentication>

    <security>
    <authentication>
    <basicAuthentication enabled="false" />
    </authentication>
    </security>
     
  2. ComputerMan

    ComputerMan Winhost Staff

    What strange things are happening? Can you describe what you're experiencing? Do you get an error message? If you do get an error message can you provide this on your next reply?
     
  3. Issue - I have a page which only authenticated users should have access to. If I type the url it goes through - it should, instead, re-direct to a login page. I said it was strange because it works fine on my local machine. Anyway - any idea why this doesn't work?
     
  4. Tabitha

    Tabitha WinHost HBIC

    Can you provide a URL to the page in question so we can view this behavior?
     
  5. Tabitha

    Tabitha WinHost HBIC

    Did you want the /personality folder to be its own web application? Setting it as an application starting point (which you can do here: https://cp.Winhost.com/sites/application.aspx) and then configuring the authorization for that directory in IIS Manager (which will create a web.config file for that directory) may be simpler.

    In any case, here's a link to a site that explains how to configure authentication in your web.config a bit better:

    http://weblogs.asp.net/gurusarkar/a...-particular-page-or-folder-in-web-config.aspx
     
    Last edited by a moderator: Oct 14, 2015
  6. Ray

    Ray

    Try creating a web.config file in your subfolder (PERSONALITY) and add this line.

    <location path="/personality/login.aspx">
    <system.web>
    <authorization>
    <allow users="*"/>
    </authorization>
    </system.web>
    </location>
     
  7. So I tried the below - still, I can access the personalitytest.htm

    <?xml version="1.0"?>

    <!--
    For more information on how to configure your ASP.NET application, please visit
    http://go.microsoft.com/fwlink/?LinkId=169433
    -->

    <configuration>
    <location path="~personality/login.aspx">
    <system.web>
    <authorization>
    <allow users="*"/>
    </authorization>
    </system.web>
    </location>
    </configuration>
     
  8. ComputerMan

    ComputerMan Winhost Staff

    Try setting the "personality" directory as a application starting point. I notice that this directory is not configured as a application folder.

    Give that a try and let us know what happens.

    Login to the control panel.

    Click on the "Sites" tab at the top.

    Click on "Manage" link next to your site account.

    Click on "Application Starting Point" box.

    Then select the directory and set it as a application starting point.
     
  9. I've set the personality folder as app starting point - no difference.

    Sorry I should have said: in my login page I have the following, not sure that makes any difference:

    if (authenticateUserEmail != null && authenticateUserRefNo != null)
    {
    FormsAuthentication.RedirectFromLoginPage(authenticateUserEmail, false);
    }
    I have removed URL re-writes and this is all my webconfig. This is so confusing! Thanks for your help though :)

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
    <system.web>
    <compilation debug="true" targetFramework="4.0">
    <assemblies>
    <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
    </assemblies>
    </compilation>
    <authentication mode="Forms">
    <forms defaultUrl="personality/personalitytest.htm" loginUrl="personality/login.aspx">
    </forms>
    </authentication>

    <membership>
    <providers>
    <clear />
    <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" />
    </providers>
    </membership>
    <profile>
    <providers>
    <clear />
    <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/" />
    </providers>
    </profile>
    <roleManager enabled="false">
    <providers>
    <clear />
    <add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/" />
    <add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" />
    </providers>
    </roleManager>
    </system.web>
    <system.webServer>
    <security>
    <authentication>
    <basicAuthentication enabled="false" />
    </authentication>

    </security>
    </system.webServer>
    </configuration>

    Webconfig in personality folder:

    <configuration>
    <location path="personality/login.aspx">
    <system.web>
    <authorization>
    <allow users="*"/>
    </authorization>
    </system.web>
    </location>
    </configuration>
     
  10. Ray

    Ray

    Try setting up wild card mapping to your account. ASP.Net membership/roles provider by default will only capture ASP.Net pages. Anything outside of that such as .htm/.html or classic ASP may not be covered in ASP.Net membership/roles provider. The work around is to setup wildcard mapping to specifically force all files through the ASP.Net engine.

    http://www.iis.net/learn/applicatio...rd-script-mapping-and-iis-integrated-pipeline
     
  11. But it works perfectly fine when I run it locally...:confused:
     

Share This Page