Installing Orchard on a Shared Hosting

Topics: Installing Orchard
Aug 11, 2011 at 5:20 PM

I used orchard to create a website for a client, on my develop / test environment it works great, but when i uploaded orchard to the production environment and i access the website it throws an exception error, security exception, is this just the .Net Trust Level?:

Security Exception

Description: The application attempted to perform an operation not allowed by the security policy.  To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file. 

Exception Details: System.Security.SecurityException: That assembly does not allow partially trusted callers.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


Stack Trace: 

[SecurityException: That assembly does not allow partially trusted callers.]
   System.Security.CodeAccessSecurityEngine.ThrowSecurityException(RuntimeAssembly asm, PermissionSet granted, PermissionSet refused, RuntimeMethodHandleInternal rmh, SecurityAction action, Object demand, IPermission permThatFailed) +259
   System.RuntimeMethodHandle.PerformSecurityCheck(Object obj, RuntimeMethodHandleInternal method, RuntimeType parent, UInt32 invocationFlags) +0
   System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +269
   System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) +12735933
   ClaySharp.Behaviors.InterfaceProxyBehavior.ConvertMissing(Func`1 proceed, Object self, Type type, Boolean isExplicit) +379
   ClaySharp.<>c__DisplayClass40.<ConvertMissing>b__3d() +50
   ClaySharp.ClayBehavior.ConvertMissing(Func`1 proceed, Object self, Type type, Boolean isExplicit) +11
   ClaySharp.<>c__DisplayClass40.<ConvertMissing>b__3d() +50
   ClaySharp.ClayBehavior.ConvertMissing(Func`1 proceed, Object self, Type type, Boolean isExplicit) +11
   ClaySharp.<>c__DisplayClass40.<ConvertMissing>b__3d() +50
   ClaySharp.ClayBehaviorCollection.Execute(Func`1 proceed, Func`3 linker) +32
   lambda_method(Closure ) +454
   ClaySharp.ClayBehavior.Convert(Func`1 proceed, Object self, Type type, Boolean isExplicit) +11
   ClaySharp.<>c__DisplayClass22.<Convert>b__1f() +50
   ClaySharp.ClayBehavior.Convert(Func`1 proceed, Object self, Type type, Boolean isExplicit) +11
   ClaySharp.<>c__DisplayClass22.<Convert>b__1f() +50
   ClaySharp.ClayBehavior.Convert(Func`1 proceed, Object self, Type type, Boolean isExplicit) +11
   ClaySharp.<>c__DisplayClass22.<Convert>b__1f() +50
   ClaySharp.ClayBehaviorCollection.Execute(Func`1 proceed, Func`3 linker) +32
   CallSite.Target(Closure , CallSite , Object ) +614
   Orchard.Core.Shapes.CoreShapes.ordered_hack(Object shape) in d:\TeamCity\Projects\Orchard-1.x\src\Orchard.Web\Core\Shapes\CoreShapes.cs:156
   Orchard.Core.Shapes.CoreShapes.ContentZone(Object Display, Object Shape, TextWriter Output) in d:\TeamCity\Projects\Orchard-1.x\src\Orchard.Web\Core\Shapes\CoreShapes.cs:143



Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1

Coordinator
Aug 11, 2011 at 6:36 PM

What is the hoster in question ? Did you check you have the medium trust in your web.config ?

Aug 11, 2011 at 6:43 PM

Sebastienros,

Thanks for your reply!

The hoster is Locaweb, located in São Paulo, Brasil, www.locaweb.com.br.

When I configured the web.config with the medium trust another error was thrown:

Configuration Error

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.

Aug 11, 2011 at 8:13 PM

the production website http://gmv.tempsite.ws

the development / test website http://www.pcmr.com.br:64739/orchard

Aug 11, 2011 at 8:40 PM

 

Server Error in '/orchard' Application.

Configuration Error

Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately. 

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.

Source Error: 

Line 112:      <add path="*" verb="*" type="System.Web.HttpNotFoundHandler" />
Line 113:    </httpHandlers>
Line 114:		<trust level="Full" originUrl="" />
Line 115:  </system.web>
Line 116:  <!-- 


Source File: e:\Home\gmv\Web\orchard\web.config    Line: 114 


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1

Coordinator
Aug 11, 2011 at 10:31 PM

This is not Meidum trust, and maybe your hoster only accepts Medium, not Full.

Aug 11, 2011 at 10:43 PM

it's a strange behavior, because my development / test environment i'm using it on a medium trust and it's working fine.

i set up the web.config to use the full trust for my application and yet i'm getting an error.

can i do something or it's just the hosting that can modify this setup?

Server Error in '/orchard' Application.

Configuration Error

Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately. 

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.

Source Error: 

 

Line 112:      <add path="*" verb="*" type="System.Web.HttpNotFoundHandler" />
Line 113:    </httpHandlers>
Line 114:		<trust level="Full" originUrl="" />
Line 115:  </system.web>
Line 116:  <!-- 


Source File: e:\Home\gmv\Web\orchard\web.config    Line: 114 


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1

Coordinator
Aug 11, 2011 at 11:22 PM

I still read Full, and you should have Medium on your hosting. Also, make sure you can change the web.config at this level of folders in your hosting envrionment. Maybe you need to change it only for the top folder.

Aug 12, 2011 at 9:32 AM

Sebastien,

Another test i did is to set up my environment to a medium .Net Trust Level and it's working fine, below i'm sending you a copy of my web.config.

<?xml version="1.0" encoding="utf-8"?>
<!-- 
    Note: As an alternative to hand editing this file you can use the 
    web admin tool to configure settings for your application. Use
    the Website->Asp.Net Configuration option in Visual Studio.
    A full list of settings and comments can be found in 
    machine.config.comments usually located in 
    \Windows\Microsoft.Net\Framework\v2.x\Config 
-->
<configuration>
  <configSections>
    <sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor">
      <section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor" requirePermission="false" />
      <section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor" requirePermission="false" />
    </sectionGroup>
    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" requirePermission="false" />
  </configSections>
  <appSettings>
    <add key="webpages:Enabled" value="false" />
    <add key="log4net.Config" value="Config\log4net.config" />
  </appSettings>
  <system.web.webPages.razor>
    <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    <pages pageBaseType="Orchard.Mvc.ViewEngines.Razor.WebViewPage">
      <namespaces>
        <add namespace="System.Web.Mvc" />
        <add namespace="System.Web.Mvc.Ajax" />
        <add namespace="System.Web.Mvc.Html" />
        <add namespace="System.Web.Routing" />
        <add namespace="System.Linq" />
        <add namespace="System.Collections.Generic" />
        <add namespace="Orchard.Mvc.Html" />
      </namespaces>
    </pages>
  </system.web.webPages.razor>
  <!-- 
        Set default transaction timeout to 30 minutes so that interactive debugging 
        is easier (default timeout is less than one minute)
  -->
  <system.transactions>
    <defaultSettings timeout="00:30:00" />
  </system.transactions>
  <system.web>
    <httpRuntime requestValidationMode="2.0" />
    <!-- 
            Set compilation debug="true" to insert debugging 
            symbols into the compiled page. Because this 
            affects performance, set this value to true only 
            during development.
    -->
    <compilation debug="false" targetFramework="4.0" batch="true" numRecompilesBeforeAppRestart="250">
      <buildProviders>
        <add extension=".csproj" type="Orchard.Environment.Extensions.Compilers.CSharpExtensionBuildProviderShim" />
      </buildProviders>
      <assemblies>
        <add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
        <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
        <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
        <add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
        <remove assembly="mscorlib" />
        <remove assembly="System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
        <remove assembly="System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
        <remove assembly="System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
        <remove assembly="System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
        <remove assembly="System.Web.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
        <remove assembly="System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
        <remove assembly="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
        <remove assembly="System.EnterpriseServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
        <remove assembly="System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
        <remove assembly="System.Runtime.Serialization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
        <remove assembly="System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
        <remove assembly="System.ServiceModel.Activation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
        <remove assembly="System.ServiceModel.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
        <remove assembly="System.Activities, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
        <remove assembly="System.ServiceModel.Activities, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
        <remove assembly="System.WorkflowServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
        <remove assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
        <remove assembly="System.Data.DataSetExtensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
        <remove assembly="System.Web.ApplicationServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
      </assemblies>
    </compilation>
    <!--
            The <authentication> section enables configuration 
            of the security authentication mode used by 
            ASP.NET to identify an incoming user. 
    -->
    <authentication mode="Forms">
      <forms loginUrl="~/Users/Account/AccessDenied" timeout="2880" />
    </authentication>
    <!--
            The <customErrors> section enables configuration 
            of what to do if/when an unhandled error occurs 
            during the execution of a request. Specifically, 
            it enables developers to configure html error pages 
            to be displayed in place of a error stack trace.
    -->
    <customErrors mode="Off" />
    <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID">
      <namespaces>
        <add namespace="System.Web.Mvc" />
        <add namespace="System.Web.Mvc.Ajax" />
        <add namespace="System.Web.Mvc.Html" />
        <add namespace="System.Web.Routing" />
        <add namespace="System.Linq" />
        <add namespace="System.Collections.Generic" />
        <add namespace="Orchard.Mvc.Html" />
      </namespaces>
    </pages>
    <httpHandlers>
      <!-- see below -->
      <clear />
      <add path="*" verb="*" type="System.Web.HttpNotFoundHandler" />
    </httpHandlers>
        <trust level="Medium" />
  </system.web>
  <!-- 
        The system.webServer section is required for running ASP.NET AJAX under Internet
        Information Services 7.0.  It is not necessary for previous version of IIS.
  -->
  <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <modules runAllManagedModulesForAllRequests="true" />
    <handlers accessPolicy="Script">
      <!-- clear all handlers, prevents executing code file extensions, prevents returning any file contents -->
      <clear />
      <!-- Return 404 for all requests via managed handler. The url routing handler will substitute the mvc request handler when routes match. -->
      <add name="NotFound" path="*" verb="*" type="System.Web.HttpNotFoundHandler" preCondition="integratedMode" requireAccess="Script" />
    </handlers>
  </system.webServer>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <probing privatePath="App_Data/Dependencies" />
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0" newVersion="3.0.0.0" />
        <bindingRedirect oldVersion="2.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>
 

Coordinator
Aug 12, 2011 at 2:22 PM

Does it mean that your issue is solved ?

Aug 12, 2011 at 2:44 PM

unfortunately not! as i said it's working on my development / test environment, but when i upload the exactly same thing to my production environment it won't work! :(

the production website http://gmv.tempsite.ws

the development / test website http://www.pcmr.com.br:64739/orchard

Aug 12, 2011 at 4:56 PM

Sebastien,

Just talked to the data center specialist and he told me that the .Net Trust Level is a custom medium, they use the medium but they customize some security levels inside it.

That's why i'm not being able to use Orchard with Locaweb. 

Thank's for your help!

Pedro Carvalho de Moraes Rego

Feb 2, 2012 at 3:13 PM

I have the same problem with Locaweb but they told that is impossible to change security to full. Do you have idea what I need to do?

I got this error

 

Server Error in '/' Application.

Security Exception

Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.

Exception Details: System.Security.SecurityException: That assembly does not allow partially trusted callers.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


Feb 2, 2012 at 4:22 PM

As pcmr said, Locaweb are using custom medium trust settings that are incompatible with normal medium trust. I would advise that you write them a strongly-worded letter explaining that you're very disappointed with their inability to support standard medium trust compatible appliations and will be looking for hosting elsewhere; request a full refund, and find a new host ;)

Coordinator
Feb 2, 2012 at 6:13 PM

+1 to that. Good hosters give full trust.

Feb 2, 2012 at 6:42 PM

Do you sugest one ?  

Coordinator
Feb 2, 2012 at 8:43 PM

I'm happy with Gearhost myself. There are plenty of good ones out there.

Developer
Feb 2, 2012 at 9:07 PM

See: http://orchard.codeplex.com/discussions/287793