locked
Forms redirect RRS feed

  • Question

  • User-1123086518 posted

    Hi there

    Within my application I currently have set up a login from a tutorial I found on the net. It works in the sense I can log in and am taken to correct pages. It uses role based authenication from SQL server. The problem lies in that when I run my program it wants me to log in straight away I can't access the top leve pages, ie index, contact etc unless I'm logged in. I'd want the user to be able to have access to all the top level files within my project except those that are under the 'Admin' folder, only logged in users should be able to log into these files. I'd imagine I have to amend web.config on the top level:

    <configuration>		
    		<connectionStrings>
    			<add name="constr" connectionString="###" providerName="System.Data.SqlClient"/>
    		</connectionStrings>
    	<system.web>				
          <compilation debug="true" strict="false" explicit="true" targetFramework="4.5" />
          <httpRuntime targetFramework="4.5"  />			
    		<authentication mode="Forms">
          <forms defaultUrl="~/Home.aspx" loginUrl="~/login.aspx" slidingExpiration="true" timeout="2880"></forms>
        </authentication>
        <authorization>
          <deny users="?" />	
        </authorization>
        <siteMap enabled ="true" defaultProvider="SiteMap">
          <providers>		  
            <add name="SiteMap" type="System.Web.XmlSiteMapProvider" siteMapFile="~/Web.sitemap" securityTrimmingEnabled="true" />		  
          </providers>
        </siteMap>	
        </system.web>
    	<appSettings>
    		<add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
    	</appSettings>
    </configuration>

    Under my 'Admin' folder I also have another config file but I guess I don't need to change this:

    <?xml version="1.0"?>
    <configuration>
        <system.web>
    		<authorization>
    			<allow roles="Administrator"/>
    			<deny users="*"/>
    		</authorization>
        </system.web>
    </configuration>
    

    Anybody understand what I'm doing wrong?..

     

     

    Wednesday, November 5, 2014 1:20 PM

Answers