473,387 Members | 1,495 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Can you find out which web.config contained your setting?

I have a custom web.config section similar to the following:

<CustomAuthSettings attr1="" attr2="">
<Locations RedirectUrl="Invalid.aspx">
<add Path="test.aspx" Roles="1,2,3" Permissions="4,5,6" />
</Locations>
</CustomAuthSettings>

Everything seems to work just fine. When I have config files in nested
folders, Attr1 and Attr2 of the CustomAuthSettings section correctly
show the values of the "closest" config file. In addition, all
locations exist in my collection from ALL config files up the folder
tree. This seems like the behavior I want. However, I have no clue
from which web.config file the location came from. I need to know this
information because I want to correctly figure out the resolved path
of each location's path attribute.

Is it possible to ascertain this information? I've been snooping
around the ConfigurationElement class with no luck.

Thanks!

Jason
Jul 22 '08 #1
5 2150
tree. This seems like the behavior I want. However, I have no clue
from which web.config file the location came from. I need to know this
information because I want to correctly figure out the resolved path
of each location's path attribute.
Simple Answer: No.

The ConfigurationManager gives the unified result.
--
Happy Hacking,
Gaurav Vaish
http://blogs.mastergaurav.com
http://eduzine.edujini-labs.com
---------------------------
Jul 23 '08 #2
That sucks. My application has defined roles and permissions. I use
ASP.Net authentication to lock out folders and files by roles using
the <authorizationsection. My problem is that I'd like to extend the
security so I could also lock out folders and pages by permissions. I
figured I'd still use the <authorizationsection for role-based
security, but if I wanted to grant access to users based on a
permission (permissions are groups into roles), I could use my own
config section. I would modify my Master page to read the config to
see if the page or folder was being restricted by permissions. I'd
then check my user's profile to see if they indeed had that
permission. I had this in mind:

<CustomAuthSettings>
<Locations RedirectUrl="AccessDenied.aspx">
<add Path="Page1.aspx" Permissions="Perm1, Perm2" />
<add Path="Page2.aspx" Permissions="Perm1" />
</Locations>
</CustomAuthSettings>

Of course, I could write code in each individual page to check for a
specific set of permissions, but having it in the web.config along
with the <authenticationsection made better sense for
maintainability. I can still get this to work, but only at a single
folder level.

The ElementInformation.Source property is NOT null if the <location>
existed in the web.config from the same directory. This sort of gets
me where I want to be. But it would be ideal to be able to set
security up the folder tree (e.g., path="subfolder/default.aspx").

Any other ideas?

Jason
Jul 23 '08 #3
re:
!I can still get this to work, but only at a single folder level.

Couldn't you try adding a setting to the AppSettings section,
of each web.config you have, which contains the name of the directory it's in ?

i.e. :

<appSettings>
<add key="directory" value="directory_name" />
</appSettings>

Then, it's easy to query the current web.config, or any web.config above it in the application's directory tree,
for the data you want, coupled with the directory's name (presumably so you can can modify it, right ?).

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"daokfella" <jj******@hotmail.comwrote in message
news:53**********************************@79g2000h sk.googlegroups.com...
That sucks. My application has defined roles and permissions. I use
ASP.Net authentication to lock out folders and files by roles using
the <authorizationsection. My problem is that I'd like to extend the
security so I could also lock out folders and pages by permissions. I
figured I'd still use the <authorizationsection for role-based
security, but if I wanted to grant access to users based on a
permission (permissions are groups into roles), I could use my own
config section. I would modify my Master page to read the config to
see if the page or folder was being restricted by permissions. I'd
then check my user's profile to see if they indeed had that
permission. I had this in mind:

<CustomAuthSettings>
<Locations RedirectUrl="AccessDenied.aspx">
<add Path="Page1.aspx" Permissions="Perm1, Perm2" />
<add Path="Page2.aspx" Permissions="Perm1" />
</Locations>
</CustomAuthSettings>

Of course, I could write code in each individual page to check for a
specific set of permissions, but having it in the web.config along
with the <authenticationsection made better sense for
maintainability. I can still get this to work, but only at a single
folder level.

The ElementInformation.Source property is NOT null if the <location>
existed in the web.config from the same directory. This sort of gets
me where I want to be. But it would be ideal to be able to set
security up the folder tree (e.g., path="subfolder/default.aspx").

Any other ideas?

Jason

Jul 23 '08 #4
Not sure what is the first problem you are trying to solve but it might
worth to check how this is done for
http://msdn.microsoft.com/en-us/library/6hbkh9s7.aspx.

Using the same mechanism would allow to define things for a particular path
file tiehr using multiple web config files or by using a single config file
with a location tag. You don"t care were it comes physcially. you just care
about the location parent element...

--
Patrice

"daokfella" <jj******@hotmail.coma écrit dans le message de groupe de
discussion :
53**********************************...oglegroups.com...
That sucks. My application has defined roles and permissions. I use
ASP.Net authentication to lock out folders and files by roles using
the <authorizationsection. My problem is that I'd like to extend the
security so I could also lock out folders and pages by permissions. I
figured I'd still use the <authorizationsection for role-based
security, but if I wanted to grant access to users based on a
permission (permissions are groups into roles), I could use my own
config section. I would modify my Master page to read the config to
see if the page or folder was being restricted by permissions. I'd
then check my user's profile to see if they indeed had that
permission. I had this in mind:

<CustomAuthSettings>
<Locations RedirectUrl="AccessDenied.aspx">
<add Path="Page1.aspx" Permissions="Perm1, Perm2" />
<add Path="Page2.aspx" Permissions="Perm1" />
</Locations>
</CustomAuthSettings>

Of course, I could write code in each individual page to check for a
specific set of permissions, but having it in the web.config along
with the <authenticationsection made better sense for
maintainability. I can still get this to work, but only at a single
folder level.

The ElementInformation.Source property is NOT null if the <location>
existed in the web.config from the same directory. This sort of gets
me where I want to be. But it would be ideal to be able to set
security up the folder tree (e.g., path="subfolder/default.aspx").

Any other ideas?

Jason

Jul 23 '08 #5
Patrice,

I think this is just what I need. I'll just reconfigure my custom
settings section to something like this:

<CustomAuthSettings RedirectUrl="AccessDenied.aspx"
Permissions="Perm1,Perm2" />

and place it in a <locationsection. Thanks.

Jason
Jul 24 '08 #6

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

Similar topics

2
by: David | last post by:
I have a book which had code that includes the line: require 'DB.php'; I know that this is from the PEAR code modules, but when I downloaded them and unpacked the directory, they "DB.php"...
2
by: Max Metral | last post by:
I'm trying to set the default behavior of customErrors in the machine.config. The documentation seems to suggest this should work, but it doesn't seem to work for me. On my development machine, I...
0
by: jhansen | last post by:
I am getting informational warnings about the following app.config and indicate the following. I am using C# visual studio 2005 and used the Settings.settings to set up my values scoped as...
12
by: Ben | last post by:
I have a group of settings that I'd like to have inherited by multiple sites. I'm trying this, but it's not working. wwwroot\group\web.config wwwroot\group\site1\web.config...
5
by: Keith | last post by:
Hello all, I have a C# Windows Forms app. It is in namespace App.GUI. It builds to Nav.exe. I have entered an application level setting using the designer. Its type is string, name is "FOO"...
10
by: salty | last post by:
.... when no one here has an answer? Does MS offer support for its programming products where that support doesn't cost an arm and a leg, but where you can at least get a response? I'm not...
0
by: 4211Jimbo | last post by:
Hello, I have recently moved from developing windows apps using vb 2003 to vb 2005 and I have a question in regards to how the applications access the machine.config file. In 2003 if I make a...
13
by: Jonny Bergdahl | last post by:
I have a ASP.Net 2.0 web application that I am trying to debug. Problem is that I can't get the error message to show in the browser. It always returns the generic error message telling me to set...
9
by: antonyliu2002 | last post by:
By default, IIS is configured to timeout a session in 20 minutes, which can be changed through the IIS config window. I use InProc sessionState mode. I can also set the session timeout in...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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,...
0
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...

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.