38

Have seen several posts about deploying MVC apps to GoDaddy. None of them seem to address the issue we are having. We have followed the advice about checking runtime versions, IIS pipeline modes, publishing and copy local to true on assemblies so all works on GoDaddy.Com.

The issue we are having is that when we try to visit the site we get a Group Policy exception because ASP.NET runtime is trying to invoke the C# compiler.

[Win32Exception (0x80004005): This program is blocked by group policy. For more information, contact your system administrator]

[ExternalException (0x80004005): Cannot execute a program. The command being executed was "C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe".........

We have gone through the publish settings and elected to precompile the site. That didn't fix the issue. Have looked at the site and there are no CS files deployed. The Global.asax file does reference a codebehind file. Since we precompiled the site we tried deleting the global.asax file and that doesn't fix the issue either.

Any thoughts would be great.

David Ferenczy Rogožan
  • 23,966
  • 9
  • 79
  • 68
Keith Franklin
  • 473
  • 1
  • 6
  • 13
  • If you precompile your views, do you still see this issue? There seem to be a few things that could cause this: 1) Views being compiled, 2) JIT Compilation on server. For both, the answer would be to ensure that your app has permissions for csc.exe (or vice-versa?). – George Stocker Jul 08 '14 at 17:40
  • In the publish settings we chose to precompile. We did change web.config to set to full trust (GoDaddy.com article said that with ASP.NET 4.0/4.5 trust should be set to full). Since this is GoDaddy.Com environment dont know how we could grant further permissions to allow CSC.EXE to run). – Keith Franklin Jul 08 '14 at 17:49
  • Please make sure you have given full permission on your site or you may ask Godaddy to give the permission for you. Please also check this documentation http://windows2008hosting.asphostportal.com/post/Cheap-ASPNET-MVC-3-Hosting-ASPHostPortal-How-to-Deploy-an-ASPNET-MVC-3-App-to-Web-Hosting-with-5cbin-Deployment.aspx and hope it will help too! –  Aug 21 '15 at 02:36
  • 1
    Did you ever find a resolution to this? – Jonathan Wood Sep 16 '15 at 03:59

6 Answers6

104

I have struggled with the same problem for months. And finally solved it. In the plesk on godaddy I changed the ASP.Net settings. First changed CAS-trustlevel to Full. Then I changed in the Web.config of my project the following:

  • Add trust level full to the system.web
  • Remove the compilers in the system.codecom
 <system.web>
    compilation debug="true" targetFramework="4.5.2"/>
    <httpRuntime targetFramework="4.5.2"/>
    <trust level="Full"/>             <!-- Just add this to the webconfig -->
 </system.web>

 <system.codedom>
              <!-- All is removed between the 2 tags-->
 </system.codedom>

and that solved my problem.

David Ferenczy Rogožan
  • 23,966
  • 9
  • 79
  • 68
Neo1779
  • 1,051
  • 1
  • 7
  • 4
  • 4
    ^^ that is the answer. Set full trust, and remove everything in the `` node. Your answer is under-voted. – Mathieu Guindon Feb 07 '16 at 23:08
  • 3
    thank you, I have been searching the solution about 2 days – ozgunb Feb 11 '16 at 09:51
  • Thank you! This is a problem I've run into recently which I haven't seen before. The `trust level="Full"` part I've had to do before, but I would never have thought to delete everything between the `system.codedom` tags. – johnnyRose Apr 28 '16 at 01:49
  • Incredible. After spending hours and hours trying to rework my connection string, commenting out those language tags inside `` solved it for me What a PITA!!! – Jonathan Wood Jul 12 '16 at 01:50
  • I had the same issue with ASP.Net Web API. Thanks a billion! This works. – mapussah Jun 11 '17 at 21:15
  • logged in just to upvote this answer. Searched for hours and tried everything. Removing the code between was the key to getting my application to work on GoDaddy. – BrianLegg Apr 04 '19 at 02:41
18

You have to remove the compilation info from the web config and it will work.

In addition to precompiling (check the box in your publish settings), add the following to your Web.Release.config:

<system.web>
  <trust level="Full" xdt:Transform="Insert" />
</system.web>
<system.codedom xdt:Transform="Remove" /> <!-- No compiling on server, GoDaddy blocks it. -->

UPDATE (1/27/2017): It appears (at least on my account) that removing system.codedom is no longer required.

Nick Kuznia
  • 1,698
  • 17
  • 27
9

I had same issue on GoDaddy hosting.

To fix it follow these steps.

Step 1: Choose "Precompile during publish" in Web Deploy settings.

Step 2: <trust level="Full" /> in <system.web> in Web.config

Balpreet Patil
  • 1,644
  • 2
  • 16
  • 16
5

I removed the Roslyn nuget package like explained in the link below, but it's a workarround.

https://social.msdn.microsoft.com/Forums/en-US/442b100a-2b88-4ac4-b655-0c1345791f15/roslyn-cscexe-web-api-2-on-hosting-server?forum=msbuild

This problem happens with a clean mvc 5 web project from visual studio 2015 template. I contacted the godaddy support, let's see what they do.

Bhavin Bhadani
  • 22,224
  • 10
  • 78
  • 108
utilsit
  • 141
  • 1
  • 8
  • What they did with me is tell me "Sorry, you have the trust level already set to Full so guess you'll need to find another hosting company." WTF am I missing here? – Jonathan Wood Sep 16 '15 at 03:53
  • They said that by phone support? – utilsit Oct 05 '15 at 17:33
  • Yes. Not in as many words, but that was there message. And they told me if I needed any privileges not supported on that account, then I'll need to find a hosting account with different privileges. – Jonathan Wood Oct 05 '15 at 17:40
3

Excellent. I also have same problem. However, my hosting vendor is arvixe.

  1. Add >trust level="Full" />" under >system.web> section in Web.config
  2. comment out >compilers> section of the >codedom> in Web.config

The problem Fixed!!!

Ortsbo
  • 175
  • 1
  • 7
2

csc.exe compiler error after publish

comment below on web.config

<!--<compilers>
  <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701" />
  <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" />
</compilers>-->