为什么我的 ASP.NET 4.0 Web 服务因 NetworkService 的编译错误而失败,但 LocalSystem 却成功
我开始收到服务器端编译错误,表明我的 Web 服务应用程序池的标识无法访问临时 ASP.NET 文件夹中的文件。如果我将应用程序池的标识从 NetworkService 更改为 LocalSystem,问题就会消失。我看不到该文件夹上的安全设置有任何问题,并且我重新运行了 aspnet_regiis -i 但没有效果。
下面包含了应用程序错误日志中出现的完整异常,但其要点是:
HttpCompileException
error CS0016: Could not write to output file 'c:\Windows\Microsoft.NET\
Framework\v4.0.30319\Temporary ASP.NET Files\kswsextensionservicesweb\f2efe503\
31c03187\App_global.asax.4gcxry4d.dll' -- 'Access is denied. '
任何人都可以解释为什么吗?奇怪的是它一直在起作用。有些东西改变了,但我不明白是什么。
Log Name: Application
Source: ASP.NET 4.0.30319.0
Date: 3/12/2011 12:41:21 PM
Event ID: 1310
Task Category: Web Event
Level: Warning
Keywords: Classic
User: N/A
Computer: NYDMTRAIN01.kayescholer.com
Description:
Event code: 3007
Event message: A compilation error has occurred.
Event time: 3/12/2011 12:41:21 PM
Event time (UTC): 3/12/2011 5:41:21 PM
Event ID: bc285ecdc00941d28070725f55ea24f1
Event sequence: 3
Event occurrence: 1
Event detail code: 0
Application information:
Application domain: /LM/W3SVC/1/ROOT/KSWSExtensionServicesWeb-2-129444252812003152
Trust level: Full
Application Virtual Path: /KSWSExtensionServicesWeb
Application Path: C:\inetpub\wwwroot\KSWSExtensionServicesWeb\
Machine name: NYDMTRAIN01
Process information:
Process ID: 3988
Process name: w3wp.exe
Account name: NT AUTHORITY\NETWORK SERVICE
Exception information:
Exception type: HttpCompileException
Exception message: (0): error CS0016: Could not write to output file 'c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\kswsextensionservicesweb\f2efe503\31c03187\App_global.asax.4gcxry4d.dll' -- 'Access is denied. '
at System.Web.Compilation.AssemblyBuilder.Compile()
at System.Web.Compilation.BuildProvidersCompiler.PerformBuild()
at System.Web.Compilation.ApplicationBuildProvider.GetGlobalAsaxBuildResult(Boolean isPrecompiledApp)
at System.Web.Compilation.BuildManager.CompileGlobalAsax()
at System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled()
at System.Web.Compilation.BuildManager.CallAppInitializeMethod()
at System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException)
Request information:
Request URL: http://nydmtrain01/KSWSExtensionServicesWeb/Services/KSWSDocumentHistoryService.svc
Request path: /KSWSExtensionServicesWeb/Services/KSWSDocumentHistoryService.svc
User host address: 172.25.43.171
User:
Is authenticated: False
Authentication Type:
Thread account name: NT AUTHORITY\NETWORK SERVICE
Thread information:
Thread ID: 6
Thread account name: NT AUTHORITY\NETWORK SERVICE
Is impersonating: False
Stack trace: at System.Web.Compilation.AssemblyBuilder.Compile()
at System.Web.Compilation.BuildProvidersCompiler.PerformBuild()
at System.Web.Compilation.ApplicationBuildProvider.GetGlobalAsaxBuildResult(Boolean isPrecompiledApp)
at System.Web.Compilation.BuildManager.CompileGlobalAsax()
at System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled()
at System.Web.Compilation.BuildManager.CallAppInitializeMethod()
at System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException)
Custom event details:
Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
<System>
<Provider Name="ASP.NET 4.0.30319.0" />
<EventID Qualifiers="32768">1310</EventID>
<Level>3</Level>
<Task>3</Task>
<Keywords>0x80000000000000</Keywords>
<TimeCreated SystemTime="2011-03-12T17:41:21.000Z" />
<EventRecordID>127544</EventRecordID>
<Channel>Application</Channel>
<Computer>NYDMTRAIN01.kayescholer.com</Computer>
<Security />
</System>
<EventData>
<Data>3007</Data>
<Data>A compilation error has occurred.</Data>
<Data>3/12/2011 12:41:21 PM</Data>
<Data>3/12/2011 5:41:21 PM</Data>
<Data>bc285ecdc00941d28070725f55ea24f1</Data>
<Data>3</Data>
<Data>1</Data>
<Data>0</Data>
<Data>/LM/W3SVC/1/ROOT/KSWSExtensionServicesWeb-2-129444252812003152</Data>
<Data>Full</Data>
<Data>/KSWSExtensionServicesWeb</Data>
<Data>C:\inetpub\wwwroot\KSWSExtensionServicesWeb\</Data>
<Data>NYDMTRAIN01</Data>
<Data>
</Data>
<Data>3988</Data>
<Data>w3wp.exe</Data>
<Data>NT AUTHORITY\NETWORK SERVICE</Data>
<Data>HttpCompileException</Data>
<Data>(0): error CS0016: Could not write to output file 'c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\kswsextensionservicesweb\f2efe503\31c03187\App_global.asax.4gcxry4d.dll' -- 'Access is denied. '
at System.Web.Compilation.AssemblyBuilder.Compile()
at System.Web.Compilation.BuildProvidersCompiler.PerformBuild()
at System.Web.Compilation.ApplicationBuildProvider.GetGlobalAsaxBuildResult(Boolean isPrecompiledApp)
at System.Web.Compilation.BuildManager.CompileGlobalAsax()
at System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled()
at System.Web.Compilation.BuildManager.CallAppInitializeMethod()
at System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException)
</Data>
<Data>http://nydmtrain01/KSWSExtensionServicesWeb/Services/KSWSDocumentHistoryService.svc</Data>
<Data>/KSWSExtensionServicesWeb/Services/KSWSDocumentHistoryService.svc</Data>
<Data>172.25.43.171</Data>
<Data>
</Data>
<Data>False</Data>
<Data>
</Data>
<Data>NT AUTHORITY\NETWORK SERVICE</Data>
<Data>6</Data>
<Data>NT AUTHORITY\NETWORK SERVICE</Data>
<Data>False</Data>
<Data> at System.Web.Compilation.AssemblyBuilder.Compile()
at System.Web.Compilation.BuildProvidersCompiler.PerformBuild()
at System.Web.Compilation.ApplicationBuildProvider.GetGlobalAsaxBuildResult(Boolean isPrecompiledApp)
at System.Web.Compilation.BuildManager.CompileGlobalAsax()
at System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled()
at System.Web.Compilation.BuildManager.CallAppInitializeMethod()
at System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException)
</Data>
</EventData>
</Event>
I started getting server-side compliation errors indicating that the identity of my web service's application pool could not access files within a temporary ASP.NET folder. If I change the identity of the application pool from NetworkService to LocalSystem, the problem goes away. I can't see any issue with the security settings on the folder and I reran aspnet_regiis -i to no effect.
The complete exception as it appears in the application error log is included below, but the gist of it is:
HttpCompileException
error CS0016: Could not write to output file 'c:\Windows\Microsoft.NET\
Framework\v4.0.30319\Temporary ASP.NET Files\kswsextensionservicesweb\f2efe503\
31c03187\App_global.asax.4gcxry4d.dll' -- 'Access is denied. '
Can anyone explain why? What's strange is that it had been working. Something changed, but I can't figure out what.
Log Name: Application
Source: ASP.NET 4.0.30319.0
Date: 3/12/2011 12:41:21 PM
Event ID: 1310
Task Category: Web Event
Level: Warning
Keywords: Classic
User: N/A
Computer: NYDMTRAIN01.kayescholer.com
Description:
Event code: 3007
Event message: A compilation error has occurred.
Event time: 3/12/2011 12:41:21 PM
Event time (UTC): 3/12/2011 5:41:21 PM
Event ID: bc285ecdc00941d28070725f55ea24f1
Event sequence: 3
Event occurrence: 1
Event detail code: 0
Application information:
Application domain: /LM/W3SVC/1/ROOT/KSWSExtensionServicesWeb-2-129444252812003152
Trust level: Full
Application Virtual Path: /KSWSExtensionServicesWeb
Application Path: C:\inetpub\wwwroot\KSWSExtensionServicesWeb\
Machine name: NYDMTRAIN01
Process information:
Process ID: 3988
Process name: w3wp.exe
Account name: NT AUTHORITY\NETWORK SERVICE
Exception information:
Exception type: HttpCompileException
Exception message: (0): error CS0016: Could not write to output file 'c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\kswsextensionservicesweb\f2efe503\31c03187\App_global.asax.4gcxry4d.dll' -- 'Access is denied. '
at System.Web.Compilation.AssemblyBuilder.Compile()
at System.Web.Compilation.BuildProvidersCompiler.PerformBuild()
at System.Web.Compilation.ApplicationBuildProvider.GetGlobalAsaxBuildResult(Boolean isPrecompiledApp)
at System.Web.Compilation.BuildManager.CompileGlobalAsax()
at System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled()
at System.Web.Compilation.BuildManager.CallAppInitializeMethod()
at System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException)
Request information:
Request URL: http://nydmtrain01/KSWSExtensionServicesWeb/Services/KSWSDocumentHistoryService.svc
Request path: /KSWSExtensionServicesWeb/Services/KSWSDocumentHistoryService.svc
User host address: 172.25.43.171
User:
Is authenticated: False
Authentication Type:
Thread account name: NT AUTHORITY\NETWORK SERVICE
Thread information:
Thread ID: 6
Thread account name: NT AUTHORITY\NETWORK SERVICE
Is impersonating: False
Stack trace: at System.Web.Compilation.AssemblyBuilder.Compile()
at System.Web.Compilation.BuildProvidersCompiler.PerformBuild()
at System.Web.Compilation.ApplicationBuildProvider.GetGlobalAsaxBuildResult(Boolean isPrecompiledApp)
at System.Web.Compilation.BuildManager.CompileGlobalAsax()
at System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled()
at System.Web.Compilation.BuildManager.CallAppInitializeMethod()
at System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException)
Custom event details:
Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
<System>
<Provider Name="ASP.NET 4.0.30319.0" />
<EventID Qualifiers="32768">1310</EventID>
<Level>3</Level>
<Task>3</Task>
<Keywords>0x80000000000000</Keywords>
<TimeCreated SystemTime="2011-03-12T17:41:21.000Z" />
<EventRecordID>127544</EventRecordID>
<Channel>Application</Channel>
<Computer>NYDMTRAIN01.kayescholer.com</Computer>
<Security />
</System>
<EventData>
<Data>3007</Data>
<Data>A compilation error has occurred.</Data>
<Data>3/12/2011 12:41:21 PM</Data>
<Data>3/12/2011 5:41:21 PM</Data>
<Data>bc285ecdc00941d28070725f55ea24f1</Data>
<Data>3</Data>
<Data>1</Data>
<Data>0</Data>
<Data>/LM/W3SVC/1/ROOT/KSWSExtensionServicesWeb-2-129444252812003152</Data>
<Data>Full</Data>
<Data>/KSWSExtensionServicesWeb</Data>
<Data>C:\inetpub\wwwroot\KSWSExtensionServicesWeb\</Data>
<Data>NYDMTRAIN01</Data>
<Data>
</Data>
<Data>3988</Data>
<Data>w3wp.exe</Data>
<Data>NT AUTHORITY\NETWORK SERVICE</Data>
<Data>HttpCompileException</Data>
<Data>(0): error CS0016: Could not write to output file 'c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\kswsextensionservicesweb\f2efe503\31c03187\App_global.asax.4gcxry4d.dll' -- 'Access is denied. '
at System.Web.Compilation.AssemblyBuilder.Compile()
at System.Web.Compilation.BuildProvidersCompiler.PerformBuild()
at System.Web.Compilation.ApplicationBuildProvider.GetGlobalAsaxBuildResult(Boolean isPrecompiledApp)
at System.Web.Compilation.BuildManager.CompileGlobalAsax()
at System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled()
at System.Web.Compilation.BuildManager.CallAppInitializeMethod()
at System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException)
</Data>
<Data>http://nydmtrain01/KSWSExtensionServicesWeb/Services/KSWSDocumentHistoryService.svc</Data>
<Data>/KSWSExtensionServicesWeb/Services/KSWSDocumentHistoryService.svc</Data>
<Data>172.25.43.171</Data>
<Data>
</Data>
<Data>False</Data>
<Data>
</Data>
<Data>NT AUTHORITY\NETWORK SERVICE</Data>
<Data>6</Data>
<Data>NT AUTHORITY\NETWORK SERVICE</Data>
<Data>False</Data>
<Data> at System.Web.Compilation.AssemblyBuilder.Compile()
at System.Web.Compilation.BuildProvidersCompiler.PerformBuild()
at System.Web.Compilation.ApplicationBuildProvider.GetGlobalAsaxBuildResult(Boolean isPrecompiledApp)
at System.Web.Compilation.BuildManager.CompileGlobalAsax()
at System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled()
at System.Web.Compilation.BuildManager.CallAppInitializeMethod()
at System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException)
</Data>
</EventData>
</Event>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
虽然错误消息表明问题特定于以下目录中的目录权限:
请检查您是否已向网络服务组授予适当/完整的权限
C:\WINDOWS\TEMP 和/或 C:\WINDOWS\TMP 目录。
While the error message indicates the problem is specific to directory rights in the following directory:
check that you have appropriate/full rights granted to the Network Service group on
C:\WINDOWS\TEMP and/or C:\WINDOWS\TMP directories.
我解决了同样的问题,但具有不同的访问权限。
系统:Windows Server 2012 Standard,德语
事件日志中的条目:
我通过向组 IIS_IUSRS 授予对 C:\TEMP 的完全访问权限来解决该问题。
I solved the same issue but with different access rights.
System: Windows Server 2012 Standard, german
Entry in event log:
I solved it by granting full access rights to C:\TEMP for the group IIS_IUSRS.