473,406 Members | 2,217 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,406 software developers and data experts.

reading web.config section

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

RoleManagerSection settings =
(RoleManagerSection)System.Configuration.Configura tionManager.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.SecurityException: Request for the
permission of type 'System.Security.Permissions.FileIOPermission, mscorlib,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

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

Thanks
Feb 27 '07 #1
5 10316
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*****@NOSPAMcubaautrement.comwrote in message
news:uz**************@TK2MSFTNGP03.phx.gbl...
Hi folks,
I'm trying to read a web.config section using

RoleManagerSection settings =
(RoleManagerSection)System.Configuration.Configura tionManager.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.SecurityException: Request for the
permission of type 'System.Security.Permissions.FileIOPermission,
mscorlib, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089' 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 "connectionStrings" perfectly but
not the "system.web"... why ???

any idea ??
thanks

"John Timney (MVP)" <x_****@timney.eclipse.co.ukwrote 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*****@NOSPAMcubaautrement.comwrote in message
news:uz**************@TK2MSFTNGP03.phx.gbl...
>Hi folks,
I'm trying to read a web.config section using

RoleManagerSection settings =
(RoleManagerSection)System.Configuration.Configur ationManager.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.SecurityException: Request for the
permission of type 'System.Security.Permissions.FileIOPermission,
mscorlib, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089' 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*****@NOSPAMcubaautrement.comwrote in message
news:ew****************@TK2MSFTNGP04.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 "connectionStrings" perfectly
but not the "system.web"... why ???

any idea ??
thanks

"John Timney (MVP)" <x_****@timney.eclipse.co.ukwrote 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*****@NOSPAMcubaautrement.comwrote in message
news:uz**************@TK2MSFTNGP03.phx.gbl...
>>Hi folks,
I'm trying to read a web.config section using

RoleManagerSection settings =
(RoleManagerSection)System.Configuration.Configu rationManager.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.SecurityException: Request for the
permission of type 'System.Security.Permissions.FileIOPermission,
mscorlib, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089' 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("appSettings"); // OK to read
GetSection("connectionString"); // OK to read
GetSection("system.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.ukwrote 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*****@NOSPAMcubaautrement.comwrote in message
news:ew****************@TK2MSFTNGP04.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 "connectionStrings" perfectly
but not the "system.web"... why ???

any idea ??
thanks

"John Timney (MVP)" <x_****@timney.eclipse.co.ukwrote 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*****@NOSPAMcubaautrement.comwrote in message
news:uz**************@TK2MSFTNGP03.phx.gbl...
Hi folks,
I'm trying to read a web.config section using

RoleManagerSection settings =
(RoleManagerSection)System.Configuration.Config urationManager.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.SecurityException: Request for the
permission of type 'System.Security.Permissions.FileIOPermission,
mscorlib, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089' 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="internal" />
<trustLevel name="High" policyFile="web_hightrust.config" />
<trustLevel name="Medium" policyFile="web_mediumtrust.config" />
<trustLevel name="Low" policyFile="web_lowtrust.config" />
<trustLevel name="Minimal" policyFile="web_minimaltrust.config"/>
</securityPolicy>
<trust
level="Full"
originUrl=""
processRequestInApplicationTrust="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*****@NOSPAMcubaautrement.comwrote in message
news:OW**************@TK2MSFTNGP03.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("appSettings"); // OK to read
GetSection("connectionString"); // OK to read
GetSection("system.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.ukwrote 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*****@NOSPAMcubaautrement.comwrote in message
news:ew****************@TK2MSFTNGP04.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 "connectionStrings" perfectly but not the
"system.web"... why ???

any idea ??
thanks

"John Timney (MVP)" <x_****@timney.eclipse.co.ukwrote in message
news:T5******************************@eclipse.ne t.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*****@NOSPAMcubaautrement.comwrote in message
news:uz**************@TK2MSFTNGP03.phx.gbl...
Hi folks,
I'm trying to read a web.config section using
>
RoleManagerSection settings =
(RoleManagerSection)System.Configuration.Confi gurationManager.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.SecurityException: Request for the permission of type
'System.Security.Permissions.FileIOPermissio n, mscorlib, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089' failed.
>
There is any security restriction on the server?? there is other way to acces config
information ??
>
Thanks
>
>




Mar 1 '07 #6

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

Similar topics

4
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...
1
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...
0
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. ...
10
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...
0
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...
0
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...
9
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): ...
0
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...
1
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"...
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
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
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...
0
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
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
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,...
0
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...

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.