473,503 Members | 2,159 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

web.config and forms authentication problem

MJ
I'm building an application that has a file structure similar to the
following:

/myapp/user_login.aspx
/myapp/user_page_1.aspx
/myapp/user_page_2.aspx
/myapp/user_page_3.aspx
/myapp/admin/admin_login.aspx
/myapp/admin/admin_page_1.aspx
/myapp/admin/admin_page_2.aspx
/myapp/admin/admin_page_3.aspx

....where "/myapp" is a virtual directory defined as an application in
IIS.

You probably get the idea - only logged-in users should have access to
the user pages under the application root, and only logged-in admins
should have access to the admin pages that are under the "admin"
subdir. Unauthenticated users/admins should be redirected to the
appropriate login form.

Using forms authentication, my web.config (located in application root
- "/myapp") currently looks like this:
<!-- begin web.config -->

<configuration>
<location>
<system.web>
<customErrors mode="Off" />
<authentication mode="Forms">
<forms name="AuthCookie" loginUrl="/myapp/user_login.aspx" />
</authentication>
<authorization>
<deny users="?" />
</authorization>
</system.web>
</location>

<location path="admin">
<system.web>
<customErrors mode="Off" />
<authentication mode="Forms">
<forms name="AdminAuthCookie"
loginUrl="/myapp/admin/admin_login.aspx" />
</authentication>
<authorization>
<deny users="?" />
</authorization>
</system.web>
</location>
</configuration>

<!-- end web.config -->
This works perfectly for the user pages... unauthenticated users are
redirected to "user_login.aspx", and after successfully logging-in
there they can access the rest of the user pages.

However, when an unauthenticated admin tries to access
"admin_page_1.aspx", instead of being redirected to the admin login
form, I get the following "Configuration Error":
<!-- begin error message -->

Parser Error Message: It is an error to use a section registered as
allowDefinition='MachineToApplication' beyond application level. This
error can be caused by a virtual directory not being configured as an
application in IIS.

Source Error:
Line 15: <system.web>
Line 16: <customErrors mode="Off" />
Line 17: <authentication mode="Forms">
Line 18: <forms name="AdminAuthCookie"
loginUrl="/myapp/admin/admin_login.aspx" />
Line 19: </authentication>

<!-- end error message -->

(line 17 is highlighted)
This message says that maybe my virtual directory is not an
application from IIS' perspective, but I've double and triple checked
that it is. Since that does not seem to be the issue, what is causing
this error? Please help! Thanks!

-MJ
Jul 21 '05 #1
1 2485
I suspect you get this error because although the myapp directory is
an application, the admin subdirectory is not.

Can you rearrange your security so that your application has only one
login page (with differing levels of access based on who logs on)?..as
the admin directory is a subdirectory of myapp, any request for a
resource in admin will cause the user to be redirected to the login
page specified in myapp/web.config...

The web.config in the admin subdirectory would then not need an
authentication tag...but would still have an authorisation tag to
allow only those users you specify as admins to have access to
resources in the admin subdirectory?

ie. some users can get to the root application directory AND the admin
directory, other users can get only to the root application
directory...all users use the same login page..

Not sure if this is what you are after?

Phill
Jul 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
16615
by: Maziar Aflatoun | last post by:
Hi, I'm trying to protect one of my subfolders from Web.config file in my root folder. Here is my directory structure / // My shopping cart /admin // Shopping cart...
2
2065
by: CW | last post by:
I have run into a really strange problem. My objective is that I only want user who have authenticated themselves to be able to access the website (and authentication is performed by form...
1
1284
by: Malik Asif Joyia | last post by:
Hello I want to implement the forms based authentication. for a sub directory in my webapplication. I have allready applied Forms based authentication in my webapplication ,, I have added a folder...
4
10548
by: Bennett Haselton | last post by:
If I add this to my web.config file: <authentication mode="Forms"> <forms name=".ASPXUSERDEMO" loginUrl="login.aspx" protection="All" timeout="60" /> </authentication> I can configure the...
9
6297
by: Benny Ng | last post by:
Hi,all, How to let the sub-directory to avoid the authentication control from Root's webconfig? I heard that we can add a new web.config to the sub-directory. And then we can slove the problem....
1
427
by: MJ | last post by:
I'm building an application that has a file structure similar to the following: /myapp/user_login.aspx /myapp/user_page_1.aspx /myapp/user_page_2.aspx /myapp/user_page_3.aspx...
5
3251
by: Andrew | last post by:
Hi, I have a default.aspx which allows the user to choose between module Admin and module B. When the user clicks either one, he will be redirected to a FormsAuthentication login page. The...
7
3758
by: Manuel | last post by:
Hi to all, I'm new in asp.net and have a problem with deploy of my application. If I up on the my server the file *.aspx and *.cs it will run perfectly, but if I try up a web.config it give this...
4
2934
by: yancheng.cheok | last post by:
Hello all, I have a web application, which I had developed few years ago with ASP .NET 1.1 Today, I would like to deploy the web application to client, using ASP .NET 2.0 + UltiDev Cassini...
0
7205
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7093
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7349
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7008
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7467
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
3177
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3168
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
746
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
399
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.