Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Configure web.config for forms authentication and page specific access

Posted on 2006-06-29
7
Medium Priority
?
299 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 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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

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

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 …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
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…

926 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