473,657 Members | 2,395 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.asp x
/myapp/user_page_2.asp x
/myapp/user_page_3.asp x
/myapp/admin/admin_login.asp x
/myapp/admin/admin_page_1.as px
/myapp/admin/admin_page_2.as px
/myapp/admin/admin_page_3.as px

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

<configuratio n>
<location>
<system.web>
<customErrors mode="Off" />
<authenticati on mode="Forms">
<forms name="AuthCooki e" loginUrl="/myapp/user_login.aspx " />
</authentication>
<authorizatio n>
<deny users="?" />
</authorization>
</system.web>
</location>

<location path="admin">
<system.web>
<customErrors mode="Off" />
<authenticati on mode="Forms">
<forms name="AdminAuth Cookie"
loginUrl="/myapp/admin/admin_login.asp x" />
</authentication>
<authorizatio n>
<deny users="?" />
</authorization>
</system.web>
</location>
</configuration>

<!-- end web.config -->
This works perfectly for the user pages... unauthenticated users are
redirected to "user_login.asp x", 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.a spx", instead of being redirected to the admin login
form, I get the following "Configurat ion Error":
<!-- begin error message -->

Parser Error Message: It is an error to use a section registered as
allowDefinition ='MachineToAppl ication' 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: <authenticati on mode="Forms">
Line 18: <forms name="AdminAuth Cookie"
loginUrl="/myapp/admin/admin_login.asp x" />
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 2510
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
16620
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 admin which needs to be protected Now in my Web.config how can I protect just the /admin folder (which is not a virtual directory) it's simply a folder in my / folder?
2
2085
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 authentication). Only a registration web page is allowed anonymous access. I have the following contents in web.config: <?xml version="1.0" encoding="utf-8" ?> <configuration>
1
1292
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 in my webapplication for the admin side of the webside and want to implement forms based authentication. so that admin users can be checked for security. i added a web.config file. but when i add the code below <authorization> <deny...
4
10566
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 application so that users who try to access a page in the application, get redirected to login.aspx where they have to sign in. (And the "signing in" is handled in the codebehind page of
9
6394
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. Virtual directory is £ºhttp://localhost/main Sub-directory is : http://localhost/main/reminder
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 /myapp/admin/admin_login.aspx /myapp/admin/admin_page_1.aspx /myapp/admin/admin_page_2.aspx
5
3256
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 problem I have is that currently, users of one module are able to access the other since I have only 1 login page. How do I prevent this ? I am not sure how to go about configuring the web.config file for having 2 modules that have a separate set of...
7
3775
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 an error page: Server Error in '/' Application. Runtime Error Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed...
4
2939
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 2.0 I locate my whole project in a folder named C:\website\GOWatch
0
8395
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8310
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8826
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8605
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7330
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6166
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4306
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.