Usage of Forms Authentication.

Discussion in 'ASP .Net' started by =?Utf-8?B?QW5kcmV3?=, Nov 4, 2005.

  1. Hi, friends,

    When we set authentication in web.config file like the follows:

    <authentication mode="Forms">
    <forms loginUrl="login.aspx" name="myAppCookie" />
    </authentication>

    we really force a user to access login.aspx first, right?

    However, in many cases, we really want to show default.aspx and some other
    ..aspx to visitors who are not our customers yet. We want them to look at our
    web pages before they decide to create an account with us. (With above
    setting, a user will have to create a new account before he/she can view any
    other pages).

    How can I implement this business requirment in asp.net app? Any reference
    paper, sample source code?

    Thanks a lot for your help.
     
    =?Utf-8?B?QW5kcmV3?=, Nov 4, 2005
    #1
    1. Advertising

  2. Hello Andrew -

    There's probably a couple of different ways to do accomplish your goal but
    the <location> and <authorization> elements in web.config are your friends.
    One way would be to put a link on your login.aspx page to a mydemo directory.
    That way when anyone connects to your website, they will be presented with
    the login page but anyone could link to the demo directory. In the web.config
    you would need to use the <location> element and allow everyone access:

    <location path="mydemo">
    <system.web>
    <authorization>
    <allow users="*" />
    </authorization>
    </system.web>
    </location>

    Or you can use use the <location> element and to allow access to individual
    pages in the default directory:

    <configuration>
    <location path="anyone.aspx">
    <system.web>
    <authorization>
    <allow users="*"/>
    </authorization>
    </system.web>
    </location>
    </configuration>

    As you can imagine, there's plenty of variations. Check out the following
    article for a pretty good overview on form authorization:

    http://www.theserverside.net/articles/showarticle.tss?id=FormAuthentication

    --
    brians
    http://www.limbertech.com


    "Andrew" wrote:

    > Hi, friends,
    >
    > When we set authentication in web.config file like the follows:
    >
    > <authentication mode="Forms">
    > <forms loginUrl="login.aspx" name="myAppCookie" />
    > </authentication>
    >
    > we really force a user to access login.aspx first, right?
    >
    > However, in many cases, we really want to show default.aspx and some other
    > .aspx to visitors who are not our customers yet. We want them to look at our
    > web pages before they decide to create an account with us. (With above
    > setting, a user will have to create a new account before he/she can view any
    > other pages).
    >
    > How can I implement this business requirment in asp.net app? Any reference
    > paper, sample source code?
    >
    > Thanks a lot for your help.
     
    =?Utf-8?B?YnJpYW5zW01DU0Rd?=, Nov 4, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andrew Connell
    Replies:
    1
    Views:
    553
    Natty Gur
    Oct 21, 2003
  2. Eric
    Replies:
    2
    Views:
    1,529
    Tommy
    Feb 13, 2004
  3. JEFF
    Replies:
    1
    Views:
    1,039
    =?Utf-8?B?YnJpYW5zW01DU0Rd?=
    Nov 12, 2007
  4. Keltex
    Replies:
    1
    Views:
    420
    Dominick Baier [DevelopMentor]
    Jan 24, 2006
  5. Eric
    Replies:
    2
    Views:
    597
Loading...

Share This Page