Security Exception

Discussion in 'General troubleshooting' started by James J, Jan 31, 2019.

  1. Hi All,

    I need some help.

    First, a little bit of background.

    For years, I was using VS 2013 to publish a site.

    Today, I redid the site in VS 2017 as on ASP.NET (.NET FrameWork).

    Old site used a db. The new site is a bunch of static razor views with one controller. No security on anything.

    The site would not load when published.

    Support said I needed to add <trust level="Full" /> to the web.config.

    This is what it now looks like:

    <system.web>
    <trust level="Full"/>
    <compilation>
    <assemblies>
    <add assembly="System.Web.Mvc, Version=5.2.4.0, Culture=neutral, PublicKeyToken=xxxxx" />
    </assemblies>
    </compilation>
    </system.web>

    Now, I get 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: 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) +549


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

    Does anyone know what the issue is?

    Thanks,

    James
     
  2. Elshadriel

    Elshadriel Winhost Staff

    Hi James,

    That is a "Full" trust issue and should have been resolved when you updated your web.config.

    1) Are you sure you made the change to the web.config file on the server and not just locally?
    2) Are you sure you are not seeing a cached page? Hit CTRL-F5 to refresh your browser.
     
  3. Hi,

    Thanks for the fast response.

    I just tried it from another pc and get the same error.

    The site is www.michaeljagodzinski.com

    This is a brand new site. I over rode the old files. The old site had an SSL Cert. I removed it through the Winhost control panel.

    I verified the config file by viewing it via ftp access.

    I am lost at this point. Any help is greatly appreciated.

    Thanks again.
     
  4. I wiped out everything and republished. I now get this error:

    Server Error in '/' Application.
    Access is denied
    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: Access is denied

    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): Access is denied]

    [ExternalException (0x80004005): Cannot execute a program. The command being executed was "E:\web\michae16\bin\roslyn\csc.exe" /shared /keepalive:"10" /noconfig /fullpaths @"F:\tempdir\v4.0.30319\root\063b3dd5\6d5a3de\zybqe1hi.cmdline".]
    System.CodeDom.Compiler.Executor.ExecWaitWithCaptureUnimpersonated(SafeUserTokenHandle userToken, String cmd, String currentDir, TempFileCollection tempFiles, String& outputName, String& errorName, String trueCmdLine) +7051914
    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) +274
    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() +10201825
    System.Web.Compilation.ApplicationBuildProvider.GetGlobalAsaxBuildResult(Boolean isPrecompiledApp) +10106768
    System.Web.Compilation.BuildManager.CompileGlobalAsax() +44
    System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() +260

    [HttpException (0x80004005): Cannot execute a program. The command being executed was "E:\web\michae16\bin\roslyn\csc.exe" /shared /keepalive:"10" /noconfig /fullpaths @"F:\tempdir\v4.0.30319\root\063b3dd5\6d5a3de\zybqe1hi.cmdline".]
    System.Web.Compilation.BuildManager.ReportTopLevelCompilationException() +62
    System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() +435
    System.Web.Compilation.BuildManager.CallAppInitializeMethod() +33
    System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +563

    [HttpException (0x80004005): Cannot execute a program. The command being executed was "E:\web\michae16\bin\roslyn\csc.exe" /shared /keepalive:"10" /noconfig /fullpaths @"F:\tempdir\v4.0.30319\root\063b3dd5\6d5a3de\zybqe1hi.cmdline".]
    System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +10075124
    System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +95
    System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254


    Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.7.3282.0
     
  5. ComputerMan

    ComputerMan Winhost Staff

Share This Page