Solved

Configure web.config for forms authentication and page specific access

Posted on 2006-06-29
7
275 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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

757 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now