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
Solved

Configure web.config for forms authentication and page specific access

Posted on 2006-06-29
7
282 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
  • 4
  • 2
7 Comments
 
LVL 27

Expert Comment

by:Sammy
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
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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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 500 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

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…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

856 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