0
I am facing a rather annoying problem for a few days that so far I have not been able to find a solution. I hired a Godaddy hosting (Windows Deluxe hosting with Plesk) to move up my projects in ASP.net. I had developed a project that until then tested on the web through the Umbler hospital and even ran normally. After some research and the desire to go to a more robust and reliable server, I chose to go to Godaddy. I decided to move the project up to Godaddy and to my surprise, an error occurred. I checked the Godaddy panel and saw that the framework that this active is 4.6.2, my project was done in 4.5.2. I decided to do a test. I did a new project following these steps in Visual Studio Community 2017:
File -> New -> Project -> ASP.NET Web Application (.NET Framework 4.6.2).
In the ASP.NET 4.6.2 template select the empty option and the reference folders have not selected any. When I opened this project, I added a Default.aspx page with a Hello World. I compiled the project, published via FTP to the Godaddy server in the release option. I accessed the link of the site and it presented the following 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 change the application’s trust level in the Configuration file.
Exception Details: System.Security.Securityexception: Request failed.
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: Request failed.]
System.Security.Codeaccesssecurityengine.Throwsecurityexception(Runtimeassembly asm, Permissionset granted, Permissionset refused, Runtimemethodhandleinternal rmh, Securityaction action, Object demand, Ipermission permThatFailed) +96
System.Security.Codeaccesssecurityengine.Throwsecurityexception(Object assemblyOrString, Permissionset granted, Permissionset refused, Runtimemethodhandleinternal rmh, Securityaction action, Object demand, Ipermission permThatFailed) +80
System.Security.Codeaccesssecurityengine.Checksethelper(Permissionset Grants, Permissionset refused, Permissionset demands, Runtimemethodhandleinternal rmh, Object assemblyOrString, Securityaction action, Boolean throwException) +288
System.Security.Codeaccesssecurityengine.Checksethelper(Compressedstack Cs, Permissionset Grants, Permissionset refused, Permissionset demands, Runtimemethodhandleinternal rmh, Runtimeassembly asm, Securityaction action) +70
System.RuntimeTypeHandle.Gettypebyname(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, Stackcrawlmarkhandle stackMark, Intptr pPrivHostBinder, Boolean loadTypeFromPartialName, Objecthandleonstack type) +0
System.RuntimeTypeHandle.Gettypebyname(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, Stackcrawlmark & stackMark, Intptr pPrivHostBinder, Boolean loadTypeFromPartialName) +70 System.RuntimeType.Gettype(String typename, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, Stackcrawlmark & stackMark) +40
System.Type.Gettype(String typename) +30
System.CodeDom.Compiler.CompilerInfo.get_IsCodeDomProviderTypeValid() +12 System.Web.Compilation.CompilationUtil.Getrecompilationhash(Compilationsection ps) +2045
System.Web.Configuration.CompilationSection.get_RecompilationHash() +107 System.Web.Compilation.BuildManager.Checktoplevelfilesuptodateinternal(Int64 cachedHash) +458
System.Web.Compilation.BuildManager.Checktoplevelfilesuptodate(Int64 cachedHash) +51
System.Web.Compilation.BuildManager.Executepreappstart() +135
System.Web.Hosting.HostingEnvironment.Initialize(Applicationmanager appManager, Iapplicationhost appHost, Iconfigmappathfactory configMapPathFactory, Hostingenvironmentparameters hostingParameters, Policylevel policyLevel, Exception appDomainCreationException) +531Version Information: Microsoft . NET Framework Version:4.0.30319; ASP.NET Version:4.6.1590.0
My web.config is as follows:
<?xml version="1.0" encoding="utf-8"?>
<!--
Para obter mais informações sobre como configurar seu aplicativo ASP.NET, visite
https://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<system.web>
<customErrors mode="Off"/>
<compilation debug="false" targetFramework="4.6.2"/>
<httpRuntime targetFramework="4.6.2"/>
</system.web>
<system.codedom>
<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=\"Web\" /optionInfer+"/>
</compilers>
</system.codedom>
</configuration>
I searched the internet and saw that it could be a matter of trust. It was then that I checked the Godaddy panel and set the CAS option to full. I saved the settings. I went to my web.config and added the following line:
<securityPolicy>
<trustLevel name="Full" policyFile="internal" />
</securityPolicy>
I tested the application again and presented a different error:
Server Error in '/' Application.
This program is blocked by group policy. For more information, contact your system Administrator
Description: An unhandled Exception occurred During the Execution of the Current web request. Please review the stack trace for more information about the error and Where it originated in the code.
Exception Details: System.ComponentModel.Win32exception: This program is blocked by group policy. For more information, contact your system Administrator
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:
[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 executed "G: Pleskvhosts Restless-game.com bumoosool bin Roslyn csc.exe" /Shared /keepalive:"10" /noconfig /fullpaths @"C: Windows Microsoft.NET Framework v4.0.30319 Temporary ASP.NET Files root da84e459 c0d920d4 yfdxpfx3.cmdline".]
System.CodeDom.Compiler.Executor.Execwaitwithcaptureunimpersonated(Safeusertokenhandle userToken, String cmd, String currentDir, Tempfilecollection tempfiles, String & outputName, String & errorName, String trueCmdLine) +6980828 System.CodeDom.Compiler.Executor.Execwaitwithcapture(Safeusertokenhandle userToken, String cmd, String currentDir, Tempfilecollection tempfiles, String & outputName, String & errorName, String trueCmdLine) +115 System.CodeDom.Compiler.Executor.Execwaitwithcapture(Intptr userToken, String cmd, String currentDir, Tempfilecollection tempfiles, String & outputName, String & errorName) +81
Microsoft.CodeDom.Providers.DotNetCompilerPlatform.Compiler.Compile(Compilerparameters options, String compilerFullPath, String Arguments, String& outputFile, Int32& nativeReturnValue) +270
Microsoft.CodeDom.Providers.DotNetCompilerPlatform.Compiler.Fromfilebatch(Compilerparameters options, String[] fileNames) +680
Microsoft.CodeDom.Providers.DotNetCompilerPlatform.Compiler.Compileassemblyfromfilebatch(Compilerparameters options, String[] fileNames) +186
System.CodeDom.Compiler.CodeDomProvider.Compileassemblyfromfile(Compilerparameters options, String[] fileNames) +24
System.Web.Compilation.AssemblyBuilder.Compile() +950
System.Web.Compilation.BuildProvidersCompiler.Performbuild() +10099549 System.Web.Compilation.BuildManager.Compilewebfile(Virtualpath virtualPath) +10098677
System.Web.Compilation.BuildManager.Getvpathbuildresultinternal(Virtualpath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) +294
System.Web.Compilation.BuildManager.Getvpathbuildresultwithnoassert(Httpcontext context, Virtualpath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) +103
System.Web.Compilation.BuildManager.Getvirtualpathobjectfactory(Virtualpath virtualPath, Httpcontext context, Boolean allowCrossApp, Boolean throwIfNotFound) +165
System.Web.Compilation.BuildManager.Createinstancefromvirtualpath(Virtualpath virtualPath, Type requiredBaseType, Httpcontext context, Boolean allowCrossApp) +43
System.Web.UI.PageHandlerFactory.Gethandlerhelper(Httpcontext context, String requestType, Virtualpath virtualPath, String physicalPath) +31 System.Web.UI.PageHandlerFactory.Gethandler(Httpcontext context, String requestType, String virtualPath, String path) +37
System.Web.Materializehandlerexecutionstep.System.Web.HttpApplication.Iexecutionstep.Execute() +339 System.Web.Httpapplication.Executestep(Iexecutionstep step, Boolean& completedSynchronously) +155Version Information: Microsoft . NET Framework Version:4.0.30319; ASP.NET Version:4.6.1590.0
I went back to the Godaddy panel and confirmed that the trust was in Full as shown below:
I climbed this empty project on Drive in case anyone needs to understand what I’m going through.
Download: https://drive.google.com/file/d/0B_SDbVzeLqJYQWpETDM1LVNmbVk/view?usp=sharing
If necessary, I can provide the FTP user who accesses only that location where the files published on Godaddy are located.
I appreciate any help :)
I had the same problem at Locaweb. The policy for running applications of most Hosts here in BR is set to Medium. In my case, as Locaweb will not change this policy, was to change Host. Host Network is the one that has the best cost benefit.
– Marcus Santos