473,703 Members | 2,653 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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

<CustomAuthSett ings attr1="" attr2="">
<Locations RedirectUrl="In valid.aspx">
<add Path="test.aspx " Roles="1,2,3" Permissions="4, 5,6" />
</Locations>
</CustomAuthSetti ngs>

Everything seems to work just fine. When I have config files in nested
folders, Attr1 and Attr2 of the CustomAuthSetti ngs 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 ConfigurationEl ement class with no luck.

Thanks!

Jason
Jul 22 '08 #1
5 2167
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 ConfigurationMa nager 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 <authorizations ection. 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 <authorizations ection 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:

<CustomAuthSett ings>
<Locations RedirectUrl="Ac cessDenied.aspx ">
<add Path="Page1.asp x" Permissions="Pe rm1, Perm2" />
<add Path="Page2.asp x" Permissions="Pe rm1" />
</Locations>
</CustomAuthSetti ngs>

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 <authentication section made better sense for
maintainability . I can still get this to work, but only at a single
folder level.

The ElementInformat ion.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="director y_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******@hotma il.comwrote in message
news:53******** *************** ***********@79g 2000hsk.googleg roups.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 <authorizations ection. 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 <authorizations ection 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:

<CustomAuthSett ings>
<Locations RedirectUrl="Ac cessDenied.aspx ">
<add Path="Page1.asp x" Permissions="Pe rm1, Perm2" />
<add Path="Page2.asp x" Permissions="Pe rm1" />
</Locations>
</CustomAuthSetti ngs>

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 <authentication section made better sense for
maintainability . I can still get this to work, but only at a single
folder level.

The ElementInformat ion.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******@hotma il.coma écrit dans le message de groupe de
discussion :
53************* *************** **...legroups .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 <authorizations ection. 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 <authorizations ection 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:

<CustomAuthSett ings>
<Locations RedirectUrl="Ac cessDenied.aspx ">
<add Path="Page1.asp x" Permissions="Pe rm1, Perm2" />
<add Path="Page2.asp x" Permissions="Pe rm1" />
</Locations>
</CustomAuthSetti ngs>

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 <authentication section made better sense for
maintainability . I can still get this to work, but only at a single
folder level.

The ElementInformat ion.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:

<CustomAuthSett ings RedirectUrl="Ac cessDenied.aspx "
Permissions="Pe rm1,Perm2" />

and place it in a <locationsectio n. Thanks.

Jason
Jul 24 '08 #6

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

Similar topics

2
3051
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" module does not exist. Is this out of date or do I need to go somewhere else to get this extra module? Thanks
2
3500
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 want customErrors off, and on my production machine I want them to go to a friendly error page (so on with a defaultRedirect). No matter what I do, I only get "customErrors off" with setting in machine.config and not web.config. Any thoughts?...
0
7811
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 application. How do I clear up these informational warnings? The 'requirePermission' attribute is not declared. Could not find schema information for the element 'applicationSettings.' Could not find schema information for the element...
12
4744
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 wwwroot\group\site2\web.config Where site1 & site2 are applications.
5
5732
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" and value is "monkey". I've tried the following ways to retrieve the value and only one works: //Returns null Configuration config = ConfigurationManager.OpenExeConfiguration(Assembly.GetEntryAssembly().Location); string monkey =...
10
1948
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 trying to be a jerk, I know that support on these newsgroups is voluntary, and I'm not jumping on anyone for not being able to answer some of the questions that are asked here. It just gets frustrating when a component in a MS product like ASP.NET
0
814
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 reference to an app setting that is not contained in the actual applications appSettings file the application automatically searched the machine.config to retrieve the value. Is this still possible in vb 2005? If so how is it done? I tried a simple...
13
5367
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 customErrors="Off". Problem is I have already done that. I have tried to activate tracing as well, by setting trace enabled="true", but accessing the trace.axd page returns a message instructing me to do just that. I have tried to figure out...
9
19649
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 web.config. So here is my question: If IIS setting has a session timeout value of 20 minutes, but my web.config setting has a session timeout of 30 minutes, will the session time out in 20 minutes or in 30 minutes?
0
8740
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
8657
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
9094
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8946
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...
1
6581
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
4673
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3108
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
2
2416
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2047
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.