Web.config causing "blocked by group policy" error
Asked Answered
M

4

37

The myriad of different web.config settings have always been a bit of a mystery to me. I'm glad Microsoft has cleaned up some of the content put there by default, but it's still causing problems.

Specifically, Visual Studio 2015 is placing the following section in the generated web.config of a standard ASP.NET MVC application.

<system.codedom>
  <compilers>
    <compiler language="c#;cs;csharp" extension=".cs"
      type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.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.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
      warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+"/>
  </compilers>
</system.codedom>

When I upload this application to my GoDaddy shared Plesk hosting account, I get the following error.

This program is blocked by group policy. For more information, contact your system administrator.

GoDaddy support is completely unwilling and unable to provide any assistance. However, I found that if I comment out the section above, the error goes away.

Does anyone know the purpose of this block or why Microsoft puts it there? My app seems to run okay without it.

Methylnaphthalene answered 16/9, 2015 at 7:16 Comment(0)
M
21

Since ASP.NET 2 is it possible to upload your site to your hosting without compiling it. Then the site will be compiled on the initial request using the compiler settings as seen in the web.config. If you pre-compile your site but still have code in the App_code folder those settings will be used to compile that code.

I think that go-daddy disabled compiling on their servers so no malicious code can somehow be inserted and compiled/executed.

As long as you don't use the App_code folder and you pre-compile your website you can delete the web.config section you mentioned.

For more information about the App_code folder check:

For more information about dynamic compilation of ASP.NET check:

Methinks answered 16/9, 2015 at 7:23 Comment(11)
@Aristos The aspx pages are compiled during compile time and placed in the bin folder. Since his section contains only .cs and .vb files and not .aspx files, his section does not apply. It might have been if the extension .aspx was mentioned in the section.Methinks
@Aristos if his .aspx files were also compiled using this section, his site wouldn't have worked without this code. (My app seems to run okay without it.)Methinks
You don't upload the codebehind pages to you hosting, you upload the binfolder and .aspx files.Methinks
@Aristos true, but not what the original poster asked.Methinks
Thanks, but why do you say "as long as I don't precompile my code I can remove this section?" Doesn't precompiling the code eliminate the need to compile on the server? (I thought the deploy feature did precompile but I'll have to check that.)Methylnaphthalene
@JonathanWood Indeed, my bad, that 'dont' had to be removed. I was a bit too quick in writing it.Methinks
I'm not really sure I understand those articles on the App_Code folder. I have modified code-behind files in the past and they got recompiled as well even though they were not in this folder.Methylnaphthalene
@JonathanWood The app_code folder is for extra helper classes you use in your .aspx files for exampleMethinks
Yes, I understand the purpose of the folder. My point is that I believe the files we be recompiled in the other folders as well. So why is the discussion specific to this folder?Methylnaphthalene
Because as I understood of your question, you precompile your code, then the only other use of the config section is the app_code folder.Methinks
My website was working in GoDaddy and I had not done that. I had to refresh everything and Prince Prasad's answer works.Mal
K
89
<system.codedom>
   <!--remove all the contents here-->
</system.codedom>

Remove all the contents inside the system.codedom tag and add

<trust level="Full"/>

inside system.web tag

<system.web>
   <trust level="Full"/>
</system.web>
Karmakarmadharaya answered 10/11, 2016 at 11:53 Comment(4)
Thank you so much. Your solution really came handy!Alleluia
Not working, but causing #49842409Vergos
Not working this was thrown #18438781Worrisome
worked with my mvc site on Arvixe in 2024! niceThinskinned
M
21

Since ASP.NET 2 is it possible to upload your site to your hosting without compiling it. Then the site will be compiled on the initial request using the compiler settings as seen in the web.config. If you pre-compile your site but still have code in the App_code folder those settings will be used to compile that code.

I think that go-daddy disabled compiling on their servers so no malicious code can somehow be inserted and compiled/executed.

As long as you don't use the App_code folder and you pre-compile your website you can delete the web.config section you mentioned.

For more information about the App_code folder check:

For more information about dynamic compilation of ASP.NET check:

Methinks answered 16/9, 2015 at 7:23 Comment(11)
@Aristos The aspx pages are compiled during compile time and placed in the bin folder. Since his section contains only .cs and .vb files and not .aspx files, his section does not apply. It might have been if the extension .aspx was mentioned in the section.Methinks
@Aristos if his .aspx files were also compiled using this section, his site wouldn't have worked without this code. (My app seems to run okay without it.)Methinks
You don't upload the codebehind pages to you hosting, you upload the binfolder and .aspx files.Methinks
@Aristos true, but not what the original poster asked.Methinks
Thanks, but why do you say "as long as I don't precompile my code I can remove this section?" Doesn't precompiling the code eliminate the need to compile on the server? (I thought the deploy feature did precompile but I'll have to check that.)Methylnaphthalene
@JonathanWood Indeed, my bad, that 'dont' had to be removed. I was a bit too quick in writing it.Methinks
I'm not really sure I understand those articles on the App_Code folder. I have modified code-behind files in the past and they got recompiled as well even though they were not in this folder.Methylnaphthalene
@JonathanWood The app_code folder is for extra helper classes you use in your .aspx files for exampleMethinks
Yes, I understand the purpose of the folder. My point is that I believe the files we be recompiled in the other folders as well. So why is the discussion specific to this folder?Methylnaphthalene
Because as I understood of your question, you precompile your code, then the only other use of the config section is the app_code folder.Methinks
My website was working in GoDaddy and I had not done that. I had to refresh everything and Prince Prasad's answer works.Mal
N
1

I realize this is a little late but I solved this problem by deleting all of the content in the element. This seems to work for both pre-compiled and otherwise.

Newmown answered 8/6, 2016 at 17:32 Comment(0)
C
1

On your server change Asp.net settings. There is a option for Trust Level. Set it to "Full".

Curculio answered 2/6, 2018 at 12:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.