Questions tagged [medium-trust]

Medium trust is the default trust level in ASP.NET. It prevents applications from accessing shared system resources and eliminates the potential for application interference.

Trust level refers to permissions set in the Web.config file (see ) that dictate what operations can and cannot be performed by Web applications. ASP.NET 3.5 and 4.0 shared hosting servers use the default Medium trust level with the addition of OleDbPermission, OdbcPermission, and a less-restrictive WebPermission.

Applications operating under a Medium trust level have no registry access, no access to the Windows event log, and cannot use ReflectionPermission (but can use Reflection). Such applications can communicate only with a defined range of network addresses and file system access is limited to the application's virtual directory hierarchy.

Using a Medium trust level prevents applications from accessing shared system resources and eliminates the potential for application interference. Adding OleDbPermission and OdbcPermission allows applications to use those data providers to access databases. WebPermission is modified to allow outbound http and https traffic.

145 questions
51
votes
1 answer

How to write to Web.Config in Medium Trust?

Uploading my first decently sized web app to my shared host provided me with a fresh set of challenges, by which I mean, sleepless nights. The issue was that I had most certainly not developed my application for medium trust (or had any clue what…
Aaron
45
votes
2 answers

Is trying to develop for Medium Trust a lost cause?

I started developing a new MVC app with Entity Framework code-first and Unity for dependency injection. I used EF5 and Unity because I thought they were supposed to work in Medium Trust. However, when I threw the tag in my…
Sam
  • 9,933
  • 12
  • 68
  • 104
23
votes
2 answers

What is Medium Trust in Asp.net?

What is Medium Trust in Asp.net? When should we use Medium Trust in Asp.net?
Amitabh
  • 59,111
  • 42
  • 110
  • 159
13
votes
5 answers

How to Automate Testing of Medium Trust Code

I would like to write automated tests that run in medium trust and fail if they require full trust. I am writing a library where some functionality is only available in full trust scenarios and I want to verify that the code I wish to run in medium…
Ian Davis
  • 3,848
  • 1
  • 24
  • 30
10
votes
4 answers

Send Email on GMail SMTP under medium trust

I need to send an email from my app, which will be running under medium trust. My current email sending code that works fine under full trust throws SecurityException under medium trust [SecurityException: Request for the permission of type…
Midhat
  • 17,454
  • 22
  • 87
  • 114
9
votes
1 answer

Expression.Compile in Medium Trust environment

When trying to compile an Expression in a medium trust web app I'm getting a MethodAccessException. Does anyone know of another way to compile an expression under medium trust or a workaround to avoid this exception? The code that throws the…
Adam Cooper
  • 8,077
  • 2
  • 33
  • 51
8
votes
3 answers

Can I use NHibernate on GoDaddy?

A comment from .Net Hosting (Flexible Medium Trust) says. Godaddy is medium trust, which means that u can't use stuff like IL emit(Nhibernate needs this for proxying) Is it true? Is there anyone using NHibernate on GoDaddy?
AAP
  • 101
  • 3
8
votes
6 answers

What are the most common, typical things to AVOID coding into my ASP.NET app in order for it to run under Medium Trust on a shared host?

What are the things that Medium Trust stops you from doing? For example, I've already learned that Medium Trust stops you from using System.IO.Path.GetTempPath(). What other things like that?
Corey Trager
  • 22,649
  • 18
  • 83
  • 121
8
votes
1 answer

System.Web.Providers doesn't work in medium trust

I have an ASP.NET WebForms app using Microsoft ASP.NET Universal Providers (NuGet) for membership and roles. Under full trust everything works fine, but when I edit web.config to specify medium trust I get this error when loading a page that…
Roger
  • 2,118
  • 1
  • 20
  • 25
8
votes
1 answer

Compiling MVC application for Medium Trust Level

I am trying to deploy an ASP.NET MVC4 site to a HostGator shared windows host. I am running into some trouble when their technical support tells me I have to compile my application for medium security. As far as I can tell the only way to set the…
sec_goat
  • 1,272
  • 1
  • 12
  • 20
8
votes
3 answers

What risk does Reflection pose? (Medium Trust)

The lack of reflection in Medium Trust hosting environments seems to cause a lot of problems for many popular web applications. Why is ReflectionPermission disabled by default with Medium Trust? What risk does reflection pose in a shared hosting…
Gabe Sumner
  • 4,978
  • 6
  • 33
  • 43
7
votes
3 answers

What application trust level is need for ASP.NET MVC framework?

i am trying to deploy simple asp.net mvc frameworkd application in may shared hosting and i get erro like this: Security Exception Description: The application attempted to perform an operation not allowed by the security policy. To grant this…
niekutis
  • 83
  • 1
  • 6
7
votes
2 answers

Simulating Shared Hosting Trust Levels

I want to simulate the trust levels of a shared hosting environment on my development machine so that there are no nasty surprises when I come to deploy my solution. I added this my setting the web.config: The…
Dan
  • 29,100
  • 43
  • 148
  • 207
7
votes
2 answers

What Reflection Permission are allowed in Medium Trust?

I want to ask that which methods/classes are allowed in Medium Trust. For example, whether these methods are allowed? GetProperties, GetMethods, Activator.CreateInstance, Assembly.Version, AssemblyName.Name Please tell me which methods are allowed.
abcplex
  • 71
  • 2
6
votes
2 answers

Is there a way to simulate medium trust in VS2010

I am looking for "easy button", where I can say run this app under medium trust.
epitka
  • 17,275
  • 20
  • 88
  • 141
1
2 3
9 10