在IIS上托管.net Core 2.1拒绝访问解决方案路径?

时间:2019-02-27 15:04:12

标签: .net iis asp.net-core-webapi .net-core-2.1

我在开发服务器上设置了.net核心2.1 Web API,它工作得很好,但是当我尝试在实时服务器上浏览站点时,出现以下错误:

Unhandled Exception: System.UnauthorizedAccessException: Access to the path 'R:\SoftCatWebApi\ETL' is denied.
   at System.IO.FileStream.ValidateFileHandle(SafeFileHandle fileHandle)
   at System.IO.FileStream.CreateFileOpenHandle(FileMode mode, FileShare share, FileOptions options)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize)
   at System.Xml.XmlDownloadManager.GetStream(Uri uri, ICredentials credentials, IWebProxy proxy, RequestCachePolicy cachePolicy)
   at System.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String role, Type ofObjectToReturn)
   at System.Xml.XmlTextReaderImpl.FinishInitUriString()
   at System.Xml.XmlTextReaderImpl..ctor(String uriStr, XmlReaderSettings settings, XmlParserContext context, XmlResolver uriResolver)
   at System.Xml.XmlReaderSettings.CreateReader(String inputUri, XmlParserContext inputContext)
   at NLog.Config.XmlLoggingConfiguration.CreateFileReader(String fileName)
   at NLog.Config.XmlLoggingConfiguration..ctor(String fileName, Boolean ignoreErrors, LogFactory logFactory)
   at NLog.LogFactory.LoadXmlLoggingConfiguration(String configFile)
   at NLog.LogFactory.LoadConfiguration(String configFile)
   at NLog.LogManager.LoadConfiguration(String configFile)
   at NLog.Web.AspNetExtensions.ConfigureNLog(IHostingEnvironment env, String configFileRelativePath)
   at ETL.Program.<>c.<BuildWebHost>b__1_0(WebHostBuilderContext hostingContext, IConfigurationBuilder config) in C:\SoftCat\Systems\SoftCatInternalWebApi\ETL\Program.cs:line 36
   at Microsoft.AspNetCore.Hosting.WebHostBuilder.BuildCommonServices(AggregateException& hostingStartupErrors)
   at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build()
   at ETL.Program.BuildWebHost(String[] args) in C:\SoftCat\Systems\SoftCatInternalWebApi\ETL\Program.cs:line 22
   at ETL.Program.Main(String[] args) in C:\SoftCat\Systems\SoftCatInternalWebApi\ETL\Program.cs:line 18

我尝试分配不同的内容,我将具有所有权限的应用程序池应用于该文件夹,并且启用了匿名身份验证。

我确实在不同的论坛上尝试了多个建议,但没有任何缝隙可以解决我的问题。

有什么建议吗?

如果我从CMD运行dll,我会得到一个不同的错误:

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

更新:

如果我单击IIS管理器中的任何选项,则会出现web.config错误

1 个答案:

答案 0 :(得分:1)

似乎,您的应用程序池标识没有访问路径的权限。 只是要确保,请具有权限的用户更改池标识。

Pool Identity

Custom Account