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 1776
走了就别回头了
走了就别回头了 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-04 16:16

    Here's how to learn about and resolve trust issues.

    1) Search your Windows\Microsoft.NET\Framework[YOUR VERSION]\CONFIG folders for the files:

    • web.config (this is the root config file)
    • web_mediumtrust.config
    • web_hightrust.config

    2) Change the web.config to say

    
    

    3) Try your ASP.NET app. Mine failed with a permission error.

    4) Diff the web_mediumtrust.config and web_hightrust.config in a diff tool, like WinMerge.

    5) Copy settings from the high to the medium one at a time and see how they affect your app. In my case, the error message referred to ConfigurationPermission, so it was easy to diagnose.

    If you can pin down the precise lines in the web_mediumtrust.config file that are blocking you, then maybe you can share that with your hosting company and have a better chance of working things out.

    More documentation here:
    http://msdn.microsoft.com/en-us/library/aa302425.aspx

    @Oli, my app IS hosted at GoDaddy and I had to do some workarounds in code when I started using Lucene.NET. I had to modify the Lucene.NET source code to not use GetTempPath and System.IO.FileInfo.

提交回复
热议问题