Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Forms Authentication question: How to have some pages open and some requiring forms authentication

Reply
Thread Tools

Forms Authentication question: How to have some pages open and some requiring forms authentication

 
 
Eric
Guest
Posts: n/a
 
      02-13-2004
I am trying to build an app where the stuff in the root directory is open to
all, but anything under the Restricted directory requires you to login and I
want to use Forms to do it. I'm having trouble getting the web.config to
work properly.

First I tried to have a second web.config in the sub directory with
authentication and authorization set to forms, but it blew up.
Next, I tried to modify the root web.config in the following manner wanting
it to only force a login when trying to navigate into the sub directory but
it takes me to the login right away:
I thought setting the path to the sub directory would restrict it to pages
in the sub directory but it's not working.
<authentication mode="Forms" >

<forms loginUrl="FormsAuthenticated/login1.aspx" name="AuthCookie"
timeout="60" path="/FormsAuthenticated"></forms>

</authentication>



<authorization>

<deny users="?" />

<allow users="*" />

</authorization>






 
Reply With Quote
 
 
 
 
Dan
Guest
Posts: n/a
 
      02-13-2004
Try this:

In your root web.config

<authentication mode="Forms">
<forms name="MyAuth" loginUrl="/public/Login.aspx" protection="All"
timeout="60" />
</authentication>

Then, in your secure folder, add a web.config which contains just this:

<configuration>
<system.web>
<authorization>
<deny users="?" />
</authorization>
</system.web>
</configuration>

Hope this helps, Dan.


"Eric" <> wrote in message
news:_b_Wb.15845$IF1.8766@fed1read01...
> I am trying to build an app where the stuff in the root directory is open

to
> all, but anything under the Restricted directory requires you to login and

I
> want to use Forms to do it. I'm having trouble getting the web.config to
> work properly.
>
> First I tried to have a second web.config in the sub directory with
> authentication and authorization set to forms, but it blew up.
> Next, I tried to modify the root web.config in the following manner

wanting
> it to only force a login when trying to navigate into the sub directory

but
> it takes me to the login right away:
> I thought setting the path to the sub directory would restrict it to pages
> in the sub directory but it's not working.
> <authentication mode="Forms" >
>
> <forms loginUrl="FormsAuthenticated/login1.aspx" name="AuthCookie"
> timeout="60" path="/FormsAuthenticated"></forms>
>
> </authentication>
>
>
>
> <authorization>
>
> <deny users="?" />
>
> <allow users="*" />
>
> </authorization>
>
>
>
>
>
>



 
Reply With Quote
 
 
 
 
Tommy
Guest
Posts: n/a
 
      02-13-2004
For each ASP.NET web application, you can only set the authentication
in the root Web.Config. However, each subfolder can have a Web.Config
with different authorization settings.

This is what I would do. Keep the Forms authentication settings in the
root Web.Config. In the root Web.Config, set the "Authorization" to
allow all access.

<authorization>
<allow users="*" /> <!-- Allow all users -->
</authorization>

Now, for folders that you want to restrict access, create a Web.Config
that contains only the "Authorization" section, and deny anonymous
access.

<authorization>
<deny users="?" />
<allow users="*" /> <!-- Allow all users -->
</authorization>

Now, the forms authentication will only restrict access to files with
extensions that are mapped to the ASP.NET ISAPI DLL. All other file
extensions will not be protected by the forms authentication.

For example, the forms authentication will protect .aspx files, but
not .htm files. To protect files with non-ASP.NET extensions, you can
go to the IIS manager, and map the file extension you want to protect
to the ASP.NET ISAPI DLL.

For example, if you want to protect .htm files with forms
authentication, you would map the .htm file extenstion to the ASP.NET
ISAPI DLL.

Tommy,

"Eric" <> wrote in message news:<_b_Wb.15845$IF1.8766@fed1read01>...
> I am trying to build an app where the stuff in the root directory is open to
> all, but anything under the Restricted directory requires you to login and I
> want to use Forms to do it. I'm having trouble getting the web.config to
> work properly.
>
> First I tried to have a second web.config in the sub directory with
> authentication and authorization set to forms, but it blew up.
> Next, I tried to modify the root web.config in the following manner wanting
> it to only force a login when trying to navigate into the sub directory but
> it takes me to the login right away:
> I thought setting the path to the sub directory would restrict it to pages
> in the sub directory but it's not working.
> <authentication mode="Forms" >
>
> <forms loginUrl="FormsAuthenticated/login1.aspx" name="AuthCookie"
> timeout="60" path="/FormsAuthenticated"></forms>
>
> </authentication>
>
>
>
> <authorization>
>
> <deny users="?" />
>
> <allow users="*" />
>
> </authorization>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
python: HTTP connections through a proxy server requiring authentication sajuptpm Python 3 01-29-2013 06:50 AM
Cisco 4402, Web Authentication function without requiring logins tyndareus Cisco 1 03-28-2009 04:52 PM
Requiring login - enforce for individual pages instead of folder? Homer J. Simpson ASP .Net 1 08-29-2007 06:52 PM
Unable to open Web project after requiring SSL Mek ASP .Net Security 1 05-07-2005 01:16 PM
Retrieving if current request is for a resource requiring authentication Matt ASP .Net 0 06-30-2004 11:57 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57