Community discussion forum

Trust Level Problem - Urgent!

Tags: .net, asp.net India
  • 3 years ago

    Hi All ASP.net geeks,

    I have just started working with .Net 2005 and developed my 1st app using ASP.net 2.0 and VB2005 with help of 'Small Business' template provided by microsoft.

    This works fine on my local server but when I deployed it on Hosting server it gives an error.U can check it by visiting www.leelakagrains.com

    that is:

    Server Error in '/' Application.

    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.



    -----------------------------------------------------

    I have burned already a week but nothing got on forums.

    The problem as I identified is :

    Server at hosting company has Trust level = Medium setting in their Machine.config.

    At my local PC/server, its Full so it runs fine but now to test I set it to 'Medium' and then tried to run the app , then I get this problem over my local server as well so its associated wid Trust Level.

    The problematic code as I identify is:

    Dim config As Configuration = WebConfigurationManager.OpenWebConfiguration("~")
     
    It's in ThemesExpressionBuilder file of Small Business template.
    If I deploy a page without master page or theme then it works fine. But I've customized n worked a lot on this theme.
    I know the problem but I cann't resolve it coz:
     
    1. My ISP will not let me host under Full Trust server.
    2.I do not know why this Theme.... file need Full trust level.
    3.What changes shud I do to run it under Medium trust level.
     
    This problem I've noticed wid every starter kit or template provided by MS for ASP.net 2.0, I wonder why MS has done this to run these template apps under full trust when its common that ISP in shared hosting cann't provide u Full trust.
    Pls helpe to solve this problem as I don want to design the whole app from the scratch. Suggest smthn so it could run under Medium trust leve.
     
    Thanks in Advance.
     
    Naveen K Agrawal
  • 3 years ago

    Naveen:

    It seems that you will be stuck with this problem (or doing a partial rewrite) unless you can obtain the cooperation of your hosting service as the resolution will require them to tweak a web server setting to permit you code to operate.  Likely they don't understand the resolution and may view it as a risk, perhaps you could read this article and use its information to appeal to them to implement the resolution it offers:

    http://support.microsoft.com/kb/320268

    This is the recommended resolution:

    To resolve this behavior, grant the FullTrust right to the remote share:
    1. On the Web server, open Administrative Tools, and then double-click Microsoft .NET Framework Configuration.
    2. Expand Runtime Security Policy, expand Machine, and then expand Code Groups.
    3. Right-click All_Code, and then click New.
    4. Select Create a new code group. Give your code group a relevant name, such as the name of the applications share. Click Next.
    5. In the Choose the condition type for this code group list, select URL.
    6. In the URL box, type the path of the share in the following format:
    file:////\\computername\sharename\*
    Note Replace computername with the name of the computer that is hosting the remote share. Replace sharename with the name of the share.
    7. Click Next. On the next page, select Use an existing permission set, and then select FullTrust.

    8. Click Next, and then click Finish.
    9. Restart Microsoft Internet Information Services (IIS) to restart the ASP.NET worker process.

    Hope this helps,

    Scott

  • 9 months ago
    Just replace ur code with this (after converting it to the vb version): // Get the Web application configuration. //Configuration configuration = WebConfigurationManager.OpenWebConfiguration("~"); // Get the 'pages' section. //PagesSection pagesSection = (PagesSection)configuration.GetSection("system.web/pages"); PagesSection pagesSection = (PagesSection)WebConfigurationManager.GetSection("system.web/pages");

Post a reply

Enter your message below

Sign in or Join us (it's free).

We'd love to hear what you think! Submit ideas or give us feedback