Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6023683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:02:29+00:00 2026-05-23T04:02:29+00:00

I am trying to make sure my ASP.Net library will work under Medium Trust.

  • 0

I am trying to make sure my ASP.Net library will work under Medium Trust. I’m having problems however in that I need to disable a bit of code if it is being run under medium trust.

How do I determine from C# if the current application is medium trust?

Specifically, I’m trying to read the customErrors section from web.config and I’m getting security errors

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T04:02:30+00:00Added an answer on May 23, 2026 at 4:02 am

    This article here describes a mechanism to determine the trust level:

    Finding out the current trust level in ASP.NET

    Here is the code just in case the link dies:

    AspNetHostingPermissionLevel GetCurrentTrustLevel() {
      foreach (AspNetHostingPermissionLevel trustLevel in
          new AspNetHostingPermissionLevel [] {
            AspNetHostingPermissionLevel.Unrestricted,
            AspNetHostingPermissionLevel.High,
            AspNetHostingPermissionLevel.Medium,
            AspNetHostingPermissionLevel.Low,
            AspNetHostingPermissionLevel.Minimal 
          } ) {
        try {
          new AspNetHostingPermission(trustLevel).Demand();
        }
        catch (System.Security.SecurityException ) {
          continue;
        }
    
        return trustLevel;
       }
    
       return AspNetHostingPermissionLevel.None;
    }
    

    I just tested it in an ASP.NET MVC3 application running at Medium and then Full trust and it does what it says on the tin.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to make a ASP.NET (C#) poll that will ask a user a
I am having problems trying to get a very simple ASP.Net application to start
I'm having a problem trying to get routing to work with ASP.NET MVC 3.0.
I'm trying to make sure that my Managed to Unmanaged calls are optimized. Is
I am trying to create a validation that checks to make sure a domain/url
I am trying to download a CSV file using HttpResponse to make sure that
I have been trying to test my application to make sure that all the
I'm trying to test the Data values that are returned from an ASP.NET MVC3
I am trying to ensure that all URLs used to access my ASP.NET MVC
I'm trying to make a setup program for an ASP.NET web site. I need

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.