Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Configure web.config for forms authentication and page specific access

Posted on 2006-06-29
7
Medium Priority
?
294 Views
Last Modified: 2011-10-03
Experts

I'm trying to configure my web app for both forms authentication and page specific access.  does the following code look right?

<configuration>
      <system.web>

            <authentication mode="Forms">
                  <forms name="admin" loginUrl="login.aspx" protection="All" path="/" timeout="60"/>
            </authentication>
            <authorization>
                  <deny users="?"/>
            </authorization>



            <!--
            The <customErrors> section enables configuration
            of what to do if/when an unhandled error occurs
            during the execution of a request. Specifically,
            it enables developers to configure html error pages
            to be displayed in place of a error stack trace.

        <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
            <error statusCode="403" redirect="NoAccess.htm" />
            <error statusCode="404" redirect="FileNotFound.htm" />
        </customErrors>
        -->
      </system.web>

      <location path="aboutUs.aspx">
            <system.web>
                  <authorization>
                        <allow users="?"/>
                  </authorization>
            </system.web>
      </location>

      <location path="contactUs.aspx">
            <system.web>
                  <authorization>
                        <allow users="?"/>
                  </authorization>
            </system.web>
      </location>

</configuration>
0
Comment
Question by:davidcahan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 27

Expert Comment

by:Sammy Ageil
ID: 17015181
I think you have to put your pages in directory then use the location
Example
create a directory called ContactUs and put contactus.aspx inside it then
 <location path="ContactUs">
          <system.web>
               <authorization>
                    <allow users="?"/>
               </authorization>
          </system.web>
     </location>


HTH
0
 
LVL 12

Expert Comment

by:deanvanrooyen
ID: 17015234
your pages can be locations!

you are missing defaultUrl = the url that the login form navigates to....

eg  <forms name=".Office" defaultUrl="content/mainportal.aspx" path="/" loginUrl="content/login.aspx" timeout="60" protection="All" slidingExpiration="true">


some examples:
http://dotnetjunkies.com/quickstart/aspplus/doc/configformat.aspx


0
 
LVL 27

Expert Comment

by:Sammy Ageil
ID: 17015292
deanvanrooyen,
Even in the example you provided the pages are included in a directory, None of the is in the root directory
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 12

Expert Comment

by:deanvanrooyen
ID: 17015963
the name="admin" should be name=".admin"

i am going to test the location stuff
0
 
LVL 12

Accepted Solution

by:
deanvanrooyen earned 2000 total points
ID: 17016112
allowOverride="true" !    :)

 <location path="aboutUs.aspx" allowOverride="true">
    <system.web>
      <authorization>
        <allow users="*"/>
      </authorization>
    </system.web>
  </location>

just to recap
1: name=".admin"
2: defaultUrl  - good practise to have this otherwise if the user hits the login page you will have to manually transfer them
3: you can use just a aspx page as a location even in the root folder of the login page, just remember to add allowOverride="true" to the location tag.
so <allow users="*"/> allows user to see this aboutus.aspx page but other pages with ? will be only authenticated users
0
 
LVL 12

Expert Comment

by:deanvanrooyen
ID: 17016121
"location" in the sense that this "object" (folder or page) can override parent configuration.
0
 

Author Comment

by:davidcahan
ID: 17016757
deanvanrooyen

thanks for all the hard work.  really appreciate the help
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question