Usage of Forms Authentication.


G

Guest

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.
 
Ad

Advertisements

G

Guest

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top