Solved

Configure web.config for forms authentication and page specific access

Posted on 2006-06-29
7
280 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

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…
One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

786 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