473,768 Members | 4,481 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

reading web.config section

alf
Hi folks,
I'm trying to read a web.config section using

RoleManagerSect ion settings =
(RoleManagerSec tion)System.Con figuration.Conf igurationManage r.GetSection("s ystem.web/roleManager");

and I get the following error on the page:

Security Exception
Description: The application attempted to perform an operation not allowed
by the security policy. To grant this application the required permission
please contact your system administrator or change the application's trust
level in the configuration file.

Exception Details: System.Security .SecurityExcept ion: Request for the
permission of type 'System.Securit y.Permissions.F ileIOPermission , mscorlib,
Version=2.0.0.0 , Culture=neutral , PublicKeyToken= b77a5c561934e08 9' failed.

There is any security restriction on the server?? there is other way to
acces config information ??

Thanks
Feb 27 '07 #1
5 10337
Your user (the account asp.net runs under) needs to have read permission to
the file, and to any config files above it in the same application.

You may need to set your applications trust level accordingly:
http://msdn2.microsoft.com/en-us/lib...93(VS.80).aspx

Regards

John Timney (MVP)
http://www.johntimney.com
http://www.johntimney.com/blog
"alf" <al*****@NOSPAM cubaautrement.c omwrote in message
news:uz******** ******@TK2MSFTN GP03.phx.gbl...
Hi folks,
I'm trying to read a web.config section using

RoleManagerSect ion settings =
(RoleManagerSec tion)System.Con figuration.Conf igurationManage r.GetSection("s ystem.web/roleManager");

and I get the following error on the page:

Security Exception
Description: The application attempted to perform an operation not allowed
by the security policy. To grant this application the required permission
please contact your system administrator or change the application's trust
level in the configuration file.

Exception Details: System.Security .SecurityExcept ion: Request for the
permission of type 'System.Securit y.Permissions.F ileIOPermission ,
mscorlib, Version=2.0.0.0 , Culture=neutral ,
PublicKeyToken= b77a5c561934e08 9' failed.

There is any security restriction on the server?? there is other way to
acces config information ??

Thanks


Feb 27 '07 #2
alf
Hi Timmey,
I can't set y application because I'm running in a hosting enviroment where
the security level is Medium.
I can read the sections: "appSetting " and "connectionStri ngs" perfectly but
not the "system.web "... why ???

any idea ??
thanks

"John Timney (MVP)" <x_****@timney. eclipse.co.ukwr ote in message
news:T5******** *************** *******@eclipse .net.uk...
Your user (the account asp.net runs under) needs to have read permission
to the file, and to any config files above it in the same application.

You may need to set your applications trust level accordingly:
http://msdn2.microsoft.com/en-us/lib...93(VS.80).aspx

Regards

John Timney (MVP)
http://www.johntimney.com
http://www.johntimney.com/blog
"alf" <al*****@NOSPAM cubaautrement.c omwrote in message
news:uz******** ******@TK2MSFTN GP03.phx.gbl...
>Hi folks,
I'm trying to read a web.config section using

RoleManagerSec tion settings =
(RoleManagerSe ction)System.Co nfiguration.Con figurationManag er.GetSection(" system.web/roleManager");

and I get the following error on the page:

Security Exception
Description: The application attempted to perform an operation not
allowed by the security policy. To grant this application the required
permission please contact your system administrator or change the
application' s trust level in the configuration file.

Exception Details: System.Security .SecurityExcept ion: Request for the
permission of type 'System.Securit y.Permissions.F ileIOPermission ,
mscorlib, Version=2.0.0.0 , Culture=neutral ,
PublicKeyToken =b77a5c561934e0 89' failed.

There is any security restriction on the server?? there is other way to
acces config information ??

Thanks



Feb 28 '07 #3
If your in a hosting environment, ask your hosting company to give you an
example that works with their trust level settings.

Regards

John Timney (MVP)
http://www.johntimney.com
http://www.johntimney.com/blog

"alf" <al*****@NOSPAM cubaautrement.c omwrote in message
news:ew******** ********@TK2MSF TNGP04.phx.gbl. ..
Hi Timmey,
I can't set y application because I'm running in a hosting enviroment
where the security level is Medium.
I can read the sections: "appSetting " and "connectionStri ngs" perfectly
but not the "system.web "... why ???

any idea ??
thanks

"John Timney (MVP)" <x_****@timney. eclipse.co.ukwr ote in message
news:T5******** *************** *******@eclipse .net.uk...
>Your user (the account asp.net runs under) needs to have read permission
to the file, and to any config files above it in the same application.

You may need to set your applications trust level accordingly:
http://msdn2.microsoft.com/en-us/lib...93(VS.80).aspx

Regards

John Timney (MVP)
http://www.johntimney.com
http://www.johntimney.com/blog
"alf" <al*****@NOSPAM cubaautrement.c omwrote in message
news:uz******* *******@TK2MSFT NGP03.phx.gbl.. .
>>Hi folks,
I'm trying to read a web.config section using

RoleManagerSe ction settings =
(RoleManagerS ection)System.C onfiguration.Co nfigurationMana ger.GetSection( "system.web/roleManager");

and I get the following error on the page:

Security Exception
Description : The application attempted to perform an operation not
allowed by the security policy. To grant this application the required
permission please contact your system administrator or change the
application 's trust level in the configuration file.

Exception Details: System.Security .SecurityExcept ion: Request for the
permission of type 'System.Securit y.Permissions.F ileIOPermission ,
mscorlib, Version=2.0.0.0 , Culture=neutral ,
PublicKeyToke n=b77a5c561934e 089' failed.

There is any security restriction on the server?? there is other way to
acces config information ??

Thanks




Feb 28 '07 #4
alf
Well, I tryed a lot to get understan with this guys from the support staff,
but nothing, they just repeat and repeat that the server has Medium Level.

Doing some test I found that:
GetSection("app Settings"); // OK to read
GetSection("con nectionString") ; // OK to read
GetSection("sys tem.web"); // Unable to read. Security Exception

I just wanna know WHY system.web is impossible to access !!!

Anyway, now I can read the entire web.config file using XmlDocument. So, my
problem is solved but I would like to investigate about it.
"John Timney (MVP)" <x_****@timney. eclipse.co.ukwr ote in message
news:uZ******** *************** *******@eclipse .net.uk...
If your in a hosting environment, ask your hosting company to give you an
example that works with their trust level settings.

Regards

John Timney (MVP)
http://www.johntimney.com
http://www.johntimney.com/blog

"alf" <al*****@NOSPAM cubaautrement.c omwrote in message
news:ew******** ********@TK2MSF TNGP04.phx.gbl. ..
>Hi Timmey,
I can't set y application because I'm running in a hosting enviroment
where the security level is Medium.
I can read the sections: "appSetting " and "connectionStri ngs" perfectly
but not the "system.web "... why ???

any idea ??
thanks

"John Timney (MVP)" <x_****@timney. eclipse.co.ukwr ote in message
news:T5******* *************** ********@eclips e.net.uk...
>>Your user (the account asp.net runs under) needs to have read permission
to the file, and to any config files above it in the same application.

You may need to set your applications trust level accordingly:
http://msdn2.microsoft.com/en-us/lib...93(VS.80).aspx

Regards

John Timney (MVP)
http://www.johntimney.com
http://www.johntimney.com/blog
"alf" <al*****@NOSPAM cubaautrement.c omwrote in message
news:uz****** ********@TK2MSF TNGP03.phx.gbl. ..
Hi folks,
I'm trying to read a web.config section using

RoleManagerS ection settings =
(RoleManager Section)System. Configuration.C onfigurationMan ager.GetSection ("system.web/roleManager");

and I get the following error on the page:

Security Exception
Descriptio n: The application attempted to perform an operation not
allowed by the security policy. To grant this application the required
permission please contact your system administrator or change the
application' s trust level in the configuration file.

Exception Details: System.Security .SecurityExcept ion: Request for the
permission of type 'System.Securit y.Permissions.F ileIOPermission ,
mscorlib, Version=2.0.0.0 , Culture=neutral ,
PublicKeyTok en=b77a5c561934 e089' failed.

There is any security restriction on the server?? there is other way to
acces config information ??

Thanks




Mar 1 '07 #5
re:
!I just wanna know WHY system.web is impossible to access !!!
!my problem is solved but I would like to investigate about it

Your ISP is assigning restrictive access permissions to some sections of web.config.

Try adding
---------------------------------------------
<location allowOverride=" true">
<system.web>
<securityPolicy >
<trustLevel name="Full" policyFile="int ernal" />
<trustLevel name="High" policyFile="web _hightrust.conf ig" />
<trustLevel name="Medium" policyFile="web _mediumtrust.co nfig" />
<trustLevel name="Low" policyFile="web _lowtrust.confi g" />
<trustLevel name="Minimal" policyFile="web _minimaltrust.c onfig"/>
</securityPolicy>
<trust
level="Full"
originUrl=""
processRequestI nApplicationTru st="true"
/>
</system.web>
</location>
-------------

....to the root web.config, and see if you can assign trust settings to your app, per:
http://msdn2.microsoft.com/en-us/lib...93(VS.80).aspx

If you can't, you'll have to talk to your ISP about allowing you to override the trust settings.


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/
=============== =============== =====
"alf" <al*****@NOSPAM cubaautrement.c omwrote in message
news:OW******** ******@TK2MSFTN GP03.phx.gbl...
Well, I tryed a lot to get understan with this guys from the support staff, but nothing, they just
repeat and repeat that the server has Medium Level.

Doing some test I found that:
GetSection("app Settings"); // OK to read
GetSection("con nectionString") ; // OK to read
GetSection("sys tem.web"); // Unable to read. Security Exception

I just wanna know WHY system.web is impossible to access !!!

Anyway, now I can read the entire web.config file using XmlDocument. So, my problem is solved but
I would like to investigate about it.
"John Timney (MVP)" <x_****@timney. eclipse.co.ukwr ote in message
news:uZ******** *************** *******@eclipse .net.uk...
>If your in a hosting environment, ask your hosting company to give you an example that works with
their trust level settings.

Regards

John Timney (MVP)
http://www.johntimney.com
http://www.johntimney.com/blog

"alf" <al*****@NOSPAM cubaautrement.c omwrote in message
news:ew******* *********@TK2MS FTNGP04.phx.gbl ...
>>Hi Timmey,
I can't set y application because I'm running in a hosting enviroment where the security level
is Medium.
I can read the sections: "appSetting " and "connectionStri ngs" perfectly but not the
"system.web". .. why ???

any idea ??
thanks

"John Timney (MVP)" <x_****@timney. eclipse.co.ukwr ote in message
news:T5****** *************** *********@eclip se.net.uk...
Your user (the account asp.net runs under) needs to have read permission to the file, and to
any config files above it in the same application.

You may need to set your applications trust level accordingly:
http://msdn2.microsoft.com/en-us/lib...93(VS.80).aspx

Regards

John Timney (MVP)
http://www.johntimney.com
http://www.johntimney.com/blog
"alf" <al*****@NOSPAM cubaautrement.c omwrote in message
news:uz***** *********@TK2MS FTNGP03.phx.gbl ...
Hi folks,
I'm trying to read a web.config section using
>
RoleManager Section settings =
(RoleManage rSection)System .Configuration. ConfigurationMa nager.GetSectio n("system.web/roleManager");
>
and I get the following error on the page:
>
Security Exception
Description : The application attempted to perform an operation not allowed by the security
policy. To grant this application the required permission please contact your system
administrat or or change the application's trust level in the configuration file.
>
Exception Details: System.Security .SecurityExcept ion: Request for the permission of type
'System.Sec urity.Permissio ns.FileIOPermis sion, mscorlib, Version=2.0.0.0 , Culture=neutral ,
PublicKeyTo ken=b77a5c56193 4e089' failed.
>
There is any security restriction on the server?? there is other way to acces config
informati on ??
>
Thanks
>
>




Mar 1 '07 #6

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

Similar topics

4
20242
by: Guinness Mann | last post by:
I'm working in VS2003.NET, with C#. I use app.config to store the connection string to my SQL Server. This works fine. Lately I've been taking work home where the connection string is different. I deal with this by having app.config.home and app.config.work files which I copy over the app.config file as required by my location.
1
1639
by: Karl Lang | last post by:
Hi I've created a new configuration section in Web.Config to hold the connection string for my database. If I have Option Strict On I get a message "Option Strict On disallows late binding" when I try to retrieve the string. Now I'd rather not turn off option strict but I'd also prefer to have my connection string in one place. Does anyone have any ideas where I'm going wrong with this? This is the code In Web.Config (I've removed some...
0
1409
by: Joel | last post by:
I am trying to do what I thought would be simple to do ie reading a section from my app.config file. I would like to have custom sections with custom attributes and be able to read/write them. <configSections> <section name="customSection" type="what should I put here"/> </configSections> <customSection fileName="test.txt" maxIdleTime="00:30:30" maxUsers="10" /> I read and tried some examples in msdn but it's sp really f.. complicated
10
9470
by: Ryan | last post by:
I've created a custom configuration section that inherits (naturally) from System.Configuration.ConfigurationSection. The configuration section is working 99% fine, however I keep coming across a ConfigurationErrorException whenever I do the following: 1. Modify and save the section in code using the System.Configuration.Configuration.Save(). 2. Refresh teh section using ConfigurationManager.RefreshSection 3. Encrypt the section,...
0
1521
by: Kbalz | last post by:
I need to read values from the Web.Config xml file, particularly the <MembershipSection. Using asp.net 2.0, C#. I'm writing a custom membership provider.. I've set up a class that inherets from MembershipProvier, and all of the override methods have been started.. but for instanace in the EnabledPasswordReset method, I want the return value to be read from the config section enablePasswordReset.. I see dozens of examples explaining...
0
1311
by: crackajaxx | last post by:
I've hunted for a while so I'm hoping someone can shed some light on this problem for me. I have an application (not a web-app, in fact this is an installed service) that relies upon its application configuration file to provide it with sensitive information. In this case, the application is talking to a website that requires credentials that are not the same as the user that the application runs as (again, its installed as a service).
9
2719
by: Milsnips | last post by:
Hi all. i'm tryng to implement the Rewrite.NET url rewritining functionality into a test project i've created, however i am hitting a problem at this line (direct from the web example): System.Collections.Specialized.NameValueCollection SectionIndex = (System.Collections.Specialized.NameValueCollection)System.Configuration.ConfigurationSettings.GetConfig("Rewrite.NET/Index"); The value always returns me null, and just to check it was...
0
8186
by: Lucky | last post by:
Hi guys, I've got a problem under reading settlings from App.config file. I've used System.Configuration to reach to the "User Settings" and "Application Settings" sections. the problem is now I'm not able read the property defined under this section. those are like this User Settings -Testing Application Settings -Test
1
2591
by: MasterLalit | last post by:
Hi, i am using a app.config file in my console application. App.config code--> <configuration> <configSections> <section name="enterpriseLibrary.ConfigurationSource" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ConfigurationSourceSection, Microsoft.Practices.EnterpriseLibrary.Common, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> </configSections> <enterpriseLibrary.ConfigurationSource...
0
9407
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
10171
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...
1
9960
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8840
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...
0
5280
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5425
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3931
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
3534
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2808
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.