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?

后端 未结 6 1798
走了就别回头了
走了就别回头了 2021-02-04 15:33

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

6条回答
  •  终归单人心
    2021-02-04 16:33

    Most shared hosts don't use a true medium trust environment because it restricts some things that are just too vital. Others restrict some extra settings for their own anal reasons.

    The best thing you can do is ask your host what settings they use for ASPNET. Ask for the specs of the trust level they're using. Find out the memory limits. Once you've got those details you should be able to replicate the scenario at a local level.

    If they won't tell you, just set your app to run in medium trust but it (obviously) won't necessarily work if they're using a modified trust level.

    Here is some information on setting trust levels in IIS.

    In general the only issue I've run into is: If you're pushing assemblies, make sure you allow partially trusted requests (it's an Assembly meta-tag) otherwise you won't be able to use them.

    Here's an extract of GoDaddy's Medium Trust information page:

    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.

    That might not map exactly to what you'll have to work around with your host (unless you're with GoDaddy) but it's a typical example.

提交回复
热议问题