Re: reading web.config section



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_john@xxxxxxxxxxxxxxxxxxxx> wrote in message
news:uZGdnfUbCvLZmXvYnZ2dnUVZ8tOmnZ2d@xxxxxxxxxxxxxxxxx
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" <alfredo@xxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:ewhk%23I1WHHA.4860@xxxxxxxxxxxxxxxxxxxxxxx
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_john@xxxxxxxxxxxxxxxxxxxx> wrote in message
news:T5Kdnaa1dIBxXHnYnZ2dnUVZ8t-nnZ2d@xxxxxxxxxxxxxxxxx
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/library/tkscy493(VS.80).aspx

Regards

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


"alf" <alfredo@xxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:uzfqmsrWHHA.1208@xxxxxxxxxxxxxxxxxxxxxxx
Hi folks,
I'm trying to read a web.config section using

RoleManagerSection settings =
(RoleManagerSection)System.Configuration.ConfigurationManager.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










.



Relevant Pages

  • Re: .NET 2.0 Trust issue on Hosted Server
    ... I would set the trust level to medium on my local copy too and try to debug... ... i just use what's in the config file: ... There's nothing on my pages that is a big security issue. ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: ASP.Net breaks after Framework 1.0 SP3
    ... SP3 includes the old channel security updates first introduced by .NET ... In any channel configuration (through code or config files), ... > application's trust level in the configuration file. ...
    (microsoft.public.dotnet.framework)
  • Re: System.Security.SecurityException: Security error
    ... You have some code that is not allowed under the trust level ... The application attempted to perform an operation not allowed> by the security policy. ... > Exception Details: System.Security.SecurityException: Security error. ... > Note that this second technique will cause all files within a given> application to be compiled in debug mode. ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: Urgent: Error While deploying ASP.net application
    ... Actually I am using MySQL database using MySQL ODBC 3.51 Driver. ... I think the trust level medium does not allow database interaction through ... > set the trust level to medium on your development machine to figure out what ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: Urgent: Error While deploying ASP.net application
    ... Dominick Baier - DevelopMentor ... I have set trust level to medium on on development machine and found that the pages which are not using database interaction are displaying but pages which interacting with database are giving secrity errror issue. ...
    (microsoft.public.dotnet.framework.aspnet.security)