Server Error in '/' Application Access is

2019-08-29 01:34发布

问题:

This is a continuation of a question I asker earlier, but that after I solved I got immediately stuck again

My Asp.net Mvc application is not loading I run it browse to it in IIS, instead I get the following

Stack Trace

[Win32Exception (0x80004005): Access is denied]

[ExternalException (0x80004005): Cannot execute a program. The command being executed was "C:\Users\JoeCampbell\source\repos\webapi\bin\roslyn\csc.exe" /shared /keepalive:"10" /noconfig /fullpaths @"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\f66da336\3058efba\3w2ezdih.cmdline".]
System.CodeDom.Compiler.Executor.ExecWaitWithCaptureUnimpersonated(SafeUserTokenHandle userToken, String cmd, String currentDir, TempFileCollection tempFiles, String& outputName, String& errorName, String trueCmdLine) +1767 System.CodeDom.Compiler.Executor.ExecWaitWithCapture(SafeUserTokenHandle userToken, String cmd, String currentDir, TempFileCollection tempFiles, String& outputName, String& errorName, String trueCmdLine) +208 System.CodeDom.Compiler.Executor.ExecWaitWithCapture(IntPtr userToken, String cmd, String currentDir, TempFileCollection tempFiles, String& outputName, String& errorName) +125
Microsoft.CodeDom.Providers.DotNetCompilerPlatform.Compiler.Compile(CompilerParameters options, String compilerFullPath, String arguments, String& outputFile, Int32& nativeReturnValue) +413
Microsoft.CodeDom.Providers.DotNetCompilerPlatform.Compiler.FromFileBatch(CompilerParameters options, String[] fileNames) +857
Microsoft.CodeDom.Providers.DotNetCompilerPlatform.Compiler.CompileAssemblyFromFileBatch(CompilerParameters options, String[] fileNames) +185
System.Web.Compilation.AssemblyBuilder.Compile() +1869
System.Web.Compilation.BuildProvidersCompiler.PerformBuild() +306
System.Web.Compilation.ApplicationBuildProvider.GetGlobalAsaxBuildResult(Boolean isPrecompiledApp) +330
System.Web.Compilation.BuildManager.CompileGlobalAsax() +49
System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() +327

[HttpException (0x80004005): Cannot execute a program. The command being executed was "C:\Users\JoeCampbell\source\repos\webapi\bin\roslyn\csc.exe" /shared /keepalive:"10" /noconfig /fullpaths @"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\f66da336\3058efba\3w2ezdih.cmdline".]
System.Web.Compilation.BuildManager.ReportTopLevelCompilationException() +73 System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() +603 System.Web.Compilation.BuildManager.CallAppInitializeMethod() +36
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +831

[HttpException (0x80004005): Cannot execute a program. The command being executed was "C:\Users\JoeCampbell\source\repos\webapi\bin\roslyn\csc.exe" /shared /keepalive:"10" /noconfig /fullpaths @"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\f66da336\3058efba\3w2ezdih.cmdline".]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +523
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +107 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +688

Things I have tried

  • Enabled Windows Authentication in Windows Features
  • Changed the Windows Authentication property to Enabled in the Properties Window

回答1:

I solved this by going to the folder listed in the stack trace and giving full permissions to webapi.localhost.net, however for you this is going to be your application pool identity.

For me it was in

"C:\Users\JoeCampbell\source\repos\webapi\bin\roslyn\csc.exe"

I then right clicked the folder > Properties > Security >

Click your application pool identity within "Group or user names:"

Click edit, and then grant Full control

Click OK