本文转自:http://www.cnblogs.com/TomGui/p/6438686.html

An error occurred while starting the application.

.NET Core X64 v4.1.1.0    |   Microsoft.AspNetCore.Hosting version 1.1.0-rtm-22752    |    Microsoft Windows 6.3.9600

报这个错,一脸懵逼,环境都按官方文档配置正确了,怎么办?

1.修改web.config文件,stdoutLogEnabled改为true,如下:

<aspNetCore processPath="dotnet" arguments=".\Dialysis.WebApi.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" />

补充一点,这个文件是在发布之后的文件里,如果没有单独配置发布文件。
就在\bin\Debug\netcoreapp1.1  里面,在根目录下有web.config文件。
注: 不在源文件的根目录下面。

另外,需要手动建 这个 logs 文件夹,因为iis不会给你自动创建。

我出这个问题的原因也是因为项目在startup的时候没有读到 nlog.config这个文件导致的错误。

在开发环境中,把这个文件的属性配置成“复制到输出目录:始终复制” 和 “生成操作:内容” 就可以了。

2.再次打开网站,还是报上述错误,别急,查看发布根目录发现多了一个Logs文件夹,打开里面的stdout_xxx.log文件

Application startup exception: System.IO.FileNotFoundException: Could not find file 'G:\FTP\DialysisWebApi\Dialysis.WebApi.xml'. File name: 'G:\FTP\DialysisWebApi\Dialysis.WebApi.xml'    at System.IO.Win32FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, FileStream parent)    at System.IO.Win32FileSystem.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, FileStream parent)    at System.IO.FileStream.Init(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)    at System.Xml.XmlSystemPathResolver.GetEntity(Uri uri, String role, Type typeOfObjectToReturn)    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 System.Xml.XmlReader.Create(String inputUri)    at System.Xml.XPath.XPathDocument..ctor(String uri, XmlSpace space)    at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenOptions.<>c__DisplayClass24_0.<IncludeXmlComments>b__0()    at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenOptions.CreateSwaggerProvider(IServiceProvider serviceProvider)    at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitTransient(TransientCallSite transientCallSite, ServiceProvider provider)    at Microsoft.Extensions.DependencyInjection.ServiceProvider.<>c__DisplayClass16_0.<RealizeService>b__0(ServiceProvider provider)    at Microsoft.Extensions.Internal.ActivatorUtilities.ConstructorMatcher.CreateInstance(IServiceProvider provider)    at Microsoft.Extensions.Internal.ActivatorUtilities.CreateInstance(IServiceProvider provider, Type instanceType, Object[] parameters)    at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass3_0.<UseMiddleware>b__0(RequestDelegate next)    at Microsoft.AspNetCore.Builder.Internal.ApplicationBuilder.Build()    at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication() Hosting environment: Production Content root path: G:\FTP\DialysisWebApi Now listening on: http://localhost:22365 Application started. Press Ctrl+C to shut down.

发现缺少文件,把文件复制到发布根目录下就解决了

发布至IIS微软官方文档

[转].Net Core Web应用发布至IIS后报“An error occurred while starting the application”错误的更多相关文章

  1. .Net Core Web应用发布至IIS后报“An error occurred while starting the application”错误

    An error occurred while starting the application. .NET Core X64 v4.1.1.0    |   Microsoft.AspNetCore ...

  2. asp.net core web api 发布到iis失败 错误500.19

    找了很久,发现是没有装DotNetCore.2.0.0-WindowsHosting.exe的原因. 还是官方文档最给力.部署时遇到问题的朋友可以参考官方文档 https://docs.microso ...

  3. ASP.NET Core Web 项目 发布的IIS7提示“HTTP Error 502.5 - Process Failure

    原因就是NUGET引用的DLL和SDK的版本不对, 你打开CMD,在项目bin目录运行dotnet xxx.dll, 会看到具体错误信息 所以你要么引用低版本的dll,要么升级最新SDK

  4. 发布tomcate时报A configuration error occurred during startup.please verify the preference field with the prompat:null

    发布tomcate时报A configuration error occurred during startup.please verify the preference field with the ...

  5. asp.net core 2.0发布到IIS报错解决方案

    大体来说,是环境的问题. 第一个错误,如图: 1. 查了网上说是文件夹权限的问题,依次设置了Everyone权限和IIS_IUSER权限,能勾选的都勾选了,然而并没有什么用,看来不是这个问题导致的. ...

  6. asp.net core 2.0发布到IIS流程及报错解决方案

      我这是个新装的服务器,没有安装任何软件. 一.发布流程 1.安装AspNetCoreModule托管模块,同时会自动安装..net core runtime DotNetCore.2.0.8-Wi ...

  7. 将.NET Core Web Api发布到Linux(CentOS 7 64)

    将.NET Core(2.1) Web Api发布到Linux(CentOS 7 64) 近来在学习linux相关的一些东西,然后正巧想试一下把core的应用程序发布到Linux,毕竟跨平台.尝试一下 ...

  8. .net core 发布到iis问题 HTTP Error 500.30 - ANCM In-Process Start Failure

    1. 没有在Program里配置IIS webBuilder.UseIIS(); 2. StartupProduction 里AutoFac容器注入错误和新版的CORS中间件已经阻止使用允许任意Ori ...

  9. SlickUpload 发布到IIS后报错

    开发时候采用slickupload控件都没问题,项目发布到IIS时发生了错误: Could not contact SlickUpload request progress handler at /S ...

随机推荐

  1. tomcat异常 Socket bind failed: [730048]

    tomcat从官网站点下载时须注意版本信息: zip格式为window压缩版. tar.gz为linux安装板. installer为window安装板. 解压后的各文件功能与作用: bin:用于放置 ...

  2. jquery call cross-domain webapi owin self-host

    <!DOCTYPE HTML> <html LANG="cn"> <head> <meta name="viewport&quo ...

  3. Django-03视图层

    5.1 视图函数 一个视图函数,简称视图,是一个简单的Python 函数,它接受Web请求并且返回Web响应.响应可以是一张网页的HTML内容,一个重定向,一个404错误,一个XML文档,或者一张图片 ...

  4. Mysql 索引原理《一》索引原理与慢查询2

    一 索引未命中 并不是说我们创建了索引就一定会加快查询速度,若想利用索引达到预想的提高查询速度的效果,我们在添加索引时,必须遵循以下问题 1 范围问题,或者说条件不明确,条件中出现这些符号或关键字:& ...

  5. OCP考试最新052题库分析整理-28

    28.Which two are true about external tables? A. They support the ORACLE_DATAPUMP access driver. B. T ...

  6. jquery遍历-filter()

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  7. “全栈2019”Java第二十六章:流程控制语句中循环语句do-while

    难度 初级 学习时间 10分钟 适合人群 零基础 开发语言 Java 开发环境 JDK v11 IntelliJ IDEA v2018.3 文章原文链接 "全栈2019"Java第 ...

  8. codeforces785E

    http://codeforces.com/contest/785/problem/E 一道经典的求逆序对的题目,可以用树状数组套平衡树解决 平衡树需要支持插入一个数,删除一个数,找比 x 小的数的个 ...

  9. [Swift]堆栈Stack的两种版本:(1)用类包装Stack (2)用泛型包装Stack

    堆栈是一个在计算机科学中经常使用的抽象数据类型.堆栈中的物体具有一个特性: 最后一个放入堆栈中的物体总是被最先拿出来, 这个特性通常称为后进先出(LIFO)队列. 堆栈中定义了一些操作. 两个最重要的 ...

  10. excel的公式:查找匹配某个值的单元格--MATCH()

    这个非常简单,没啥说的,D1位置是显示这个值所在的行数,如果是跨表,就在匹配区域前面加上  sheetName!