+1-888-365-2779
Try Now
More in this section

Forums / Deployment / Simulate in development environment medium trust

Simulate in development environment medium trust

14 posts, 0 answered
  1. Vangelis
    Vangelis avatar
    153 posts
    Registered:
    07 Jan 2006
    02 Apr 2008
    Link to this post
    Hi,

    Does anyone can post detailed instructions how to setup medium trust environment in development machine, just to simulate hosting providers running in this mode?

    This will help minimize errors before uploading project in production machine.

    I have found this in some other posts

    Set in the web.config:

    <system.web>
     <trust level="Medium" />


    Best regards

    Vagelis
  2. Nikifor
    Nikifor avatar
    232 posts
    Registered:
    18 May 2013
    03 Apr 2008
    Link to this post
    Hello Vagelis,

    There are several steps which should be followed for setting your application to work in Medium Trust Environment. You could find them in the User Manual, section Medium Trust Support. Still, for your convenience, here are the steps you need to follow:

    Make the following changes in your web.config file:

    1. As mentioned in your post, the following script has to be added in the <system.web> tag:
    <system.web> 
      <trust level="Medium" /> 
      ... 
    <system.web>


    2. You have to make sure that the HealthMonitoring option is set to false:
    <healthMonitoring enabled="false" heartbeatInterval="0"


    3. You must make sure that you have not enabled Workflow for the modules or pages in any part of the web.config file:
    AllowPageWorkflow=”False” 
    AllowWorkflow=”False” 

    4. Make sure that the following line is commented out:
    <!--add name="SitefinityXml" securityProviderName="" type="Telerik.Lists.Data.XmlProvider, Telerik.Lists.Data" dataFile="~/App_Data/Lists.xml" visible="true" /--> 


    Please let us know if, after making all the adjustments described above, you still experience any of the issues for which you have reported to us.

    Best wishes,
    Nikifor
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. Josh
    Josh avatar
    1 posts
    Registered:
    28 Apr 2008
    03 May 2008
    Link to this post

    I followed the above posted instructions as well, but when I run the site, I receive the permission error for system.reflection:

    System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.ReflectionPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.


    Is there anything I did incorrectly?

  4. Ivan
    Ivan avatar
    478 posts
    Registered:
    16 Jun 2015
    14 May 2008
    Link to this post
    Hi Josh,

    Generally, servers allow RestrictedMemberAcces for ReflectionPermission while running in medium trust. In order to set up your local medium trust to allow ReflectionPermission, please do following:

    1. Navigate to root\windows\Microsoft.NET\Framework\2.x\CONFIG.
    2. Open the web_mediumtrust.config file.
    3. Make sure you have following line as a child of SecurityClasses:
    <SecurityClass Name="ReflectionPermission" Description="System.Security.Permissions.ReflectionPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/> 
    4. Make sure you have following line among IPermission settings :
    <IPermission class="ReflectionPermission" version="1" Flags="RestrictedMemberAccess"/> 

    Save the file and try to run Sitefinity again. 

    Thank you for your patience and let us know if we can help you with anything else.

    Sincerely yours,
    Ivan
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  5. Jaime Weise
    Jaime Weise avatar
    120 posts
    Registered:
    02 Nov 2008
    14 Aug 2009
    Link to this post
    The whold reason we need help to use medium trust is that we don't have access to the machine.config and want to run in a secure environment. Is there any way to setup sitefinity under these conditions. The main error so far I am seeing is file access against the web.config. File operations are a little more limited under medium trust.

    Any help would be greatly appreciated. I followed the steps without any success.
  6. Parvan
    Parvan avatar
    151 posts
    Registered:
    24 Sep 2012
    17 Aug 2009
    Link to this post
    Hello jaime,

    Thank you for using our services.

    Yes - it is possible to setup Sitefinity in medium trust environment.

    1. It is important first to run the application in full trust (for example in your dev environment. This will generate the needed dll for Newsletter module.
    2. Set the medium trust and configure web.config file. Follow Nikifor's instructions.

    I hope this helps you.

    Sincerely yours,
    Parvan
    the Telerik team

    Instantly find answers to your questions on the newTelerik Support Portal.
    Check out the tipsfor optimizing your support resource searches.
  7. Ali
    Ali avatar
    37 posts
    Registered:
    11 Jun 2008
    22 Oct 2009
    Link to this post
    I am having no luck with the web.config fixes. I am even getting a new error when trying to add

    <trust level="Medium" /> 

    I get the following error:

    "Parser Error Message: This configuration section cannot be used at this path.  This happens when the site administrator has locked access to this section using <location allowOverride="false"> from an inherited configuration file."

    I have gone through and turned off all workflow sections, and I am running the community edition so the page workflow shouldn't have been enabled and I went through and changed everything to false as instructed.

    <providers> 
            <clear /> 
            <add connectionStringName="DefaultConnection" allowPageHistory="False" 
              allowPageWorkflow="False" name="Sitefinity" type="Telerik.Cms.Data.DefaultProvider, Telerik.Cms.Data" /> 
          </providers> 

    <add name="Generic_Content" urlRewriteFormat="[Publication_Date]/[Title].aspx" urlDateTimeFormat="yy-MM-dd" urlWhitespaceChar="_" visible="True" defaultMetaField="Name" securityProviderName="" allowLocalization="False" allowVersioning="True" allowWorkflow="False" allowComments="false" commentsModeration="true" versioningProviderName="" connectionStringName="GenericContentConnection" type="Telerik.Cms.Engine.Data.Providers.DefaultProvider, Telerik.Cms.Engine.Data"/> 
            <add name="News" urlRewriteFormat="[Publication_Date]/[Title].aspx" urlDateTimeFormat="yy-MM-dd" urlWhitespaceChar="_" visible="False" defaultMetaField="Title" securityProviderName="" allowVersioning="True" applicationName="/News" versioningProviderName="" commentsModeration="true" connectionStringName="GenericContentConnection" type="Telerik.News.Data.DefaultNewsProvider, Telerik.News.Data" /> 
            <add name="Blogs" urlRewriteFormat="[Publication_Date]/[Title].aspx" urlDateTimeFormat="yy-MM-dd" urlWhitespaceChar="_" visible="False" defaultMetaField="Title" applicationName="/Blogs" allowVersioning="True" allowLocalization="False" localizationProviderName="" allowWorkflow="False" securityProviderName="" versioningProviderName="" connectionStringName="GenericContentConnection" type="Telerik.Blogs.Data.DefaultBlogProvider, Telerik.Blogs.Data"/> 
            <add name="Libraries" urlRewriteFormat="~/{Provider}/{LibraryName}/[Name].sflb" urlDateTimeFormat="yy-MM-dd" urlWhitespaceChar="_" visible="False" defaultMetaField="Name" applicationName="/Libraries" allowVersioning="True" allowLocalization="False" localizationProviderName="" allowWorkflow="False" securityProviderName="" versioningProviderName="" connectionStringName="GenericContentConnection" type="Telerik.Libraries.Data.DefaultProvider, Telerik.Libraries.Data" tagEditorTemplate="~/Sitefinity/Admin/ControlTemplates/Libraries/BatchTagsEditor.ascx"/> 

    I am at a loss. I have attached an image for reference of the error.

    What else can be done?
  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    22 Oct 2009
    Link to this post
    Hello Ali,

    The error is pretty clear - your host does not allow specifying and setting the connection string through user's web.config file. By default the server runs in medium trust, so that you do no have to specify the level. If you remove this node from your web.config file the error should disappear.
    As  for the medium trust you should also disable the HealthMonitoring - it is not supported in medium trust.

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  9. Jaime Weise
    Jaime Weise avatar
    120 posts
    Registered:
    02 Nov 2008
    22 Oct 2009
    Link to this post
    I would suggest one thing. In your development environment you should add the trust element to medium. On the server however, since it will have been set to medium in the server machine.config, you should remove that element altogether.

    When I had the trust element in the server web.config I still got the security exception when it was set to Level=Medium. Once I removed the <trust Level=Medium /> it worked fine. It could be the way that medium trust security was implemented in the web.config checks to make sure no one is trying to override and lower the trust via the trust element. I don't know if that is a microsoft oversight or a hack in place on the server in my case but that helped me. 

    Therefore, use the <trust Level=Medium /> is only to make sure that the application functions on your dev machine properly under medium trust conditions.
  10. Ali
    Ali avatar
    37 posts
    Registered:
    11 Jun 2008
    23 Oct 2009
    Link to this post
    Health monitoring is turned off and i have removed the trust section as well. I am still getting this error [See: Attached]

    Sorry for my ignorance.
  11. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    23 Oct 2009
    Link to this post
    Hi Ali,

    It seems that your host does not support the default configuration for Medium Trust level and Sitefinity's providers cannot be initialized.

    Regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  12. Albin Malmgren
    Albin Malmgren avatar
    3 posts
    Registered:
    24 Sep 2009
    23 Oct 2009
    Link to this post
    Hi, I have same problem as Ali and I hope for some solution. I  don't now how to solve this? I've followed the steps above and still get this:


    [SecurityException: That assembly does not allow partially trusted callers.]   Nolics.ORMapper.DataProviders.SQLDataProvider.Open() +123   Telerik.DataAccess.NolicsHelper.SetConnection(String connectionName, String providerName) +830   Telerik.Cms.Data.DefaultProvider.Initialize(String name, NameValueCollection config) +214   Telerik.ManagerBase`1.InstantiateProvider(ProviderSettings providerSettings, Type providerType) +673   Telerik.ManagerBase`1.InstantiateProvider(ProviderSettings providerSettings) +91   Telerik.ManagerBase`1.SetProvider(String providerName) +203   Telerik.ManagerBase`1..ctor(String providerName) +89   Telerik.ManagerBase`1..ctor() +11   Telerik.Cms.Web.UrlHelper.Initialize(CmsHttpModule cmsModule) +38   Telerik.Cms.Web.CmsHttpModule.Init(HttpApplication context) +86   System.Web.HttpApplication.InitModulesCommon() +65   System.Web.HttpApplication.InitModules() +43   System.Web.HttpApplication.InitInternal(HttpContext context, HttpApplicationState state, MethodInfo[] handlers) +729   System.Web.HttpApplicationFactory.GetNormalApplicationInstance(HttpContext context) +298   System.Web.HttpApplicationFactory.GetApplicationInstance(HttpContext context) +107   System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +289
    My hostprovider run this medium trust config.
    http://wiki.binero.se/Programmering/Sidans_titel#Hur_ser_er_Medium_Trust-konfiguration_ut.3f
    Any ideas? 
  13. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    28 Oct 2009
    Link to this post
    Hello Albin Malmgren,

    The configuration seems to be correct, but there should be something else that blocks the initializing of the providers. I suggest that you should try one of your host partners where Sitefinity will run without problems.

    Greetings,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  14. Mehdi
    Mehdi avatar
    21 posts
    Registered:
    19 Feb 2009
    18 Nov 2009
    Link to this post
    here is a link for Sitefinity running on shared hosting with medium trust
    http://mehdimirza.blogspot.com/2009/11/installing-sitefinity-on-shared-hosting.html

    Thanks

    Mehdi
Register for webinar
14 posts, 0 answered