问:
.Net Core: Application startup exception: System.IO.FileNotFoundException: The configuration file 'appsettings.json' was not found and is not optional.
 
答:
问题代码:
public Startup()
{
var builder = new ConfigurationBuilder().AddJsonFile("AppSetting.json");
Configuration = builder.Build();
}
 
 
正确代码:
public Startup(IHostingEnvironment environment)
{
var builder = new ConfigurationBuilder().SetBasePath(environment.ContentRootPath).AddJsonFile("AppSetting.json");
Configuration = builder.Build();
}

The configuration file 'appsettings.json' was not found and is not optional的更多相关文章

  1. net core 2 读取appsettings.json

    问: .Net Core: Application startup exception: System.IO.FileNotFoundException: The configuration file ...

  2. .net core 读取、修改配置文件appsettings.json

    .net core 设置读取JSON配置文件 appsettings.json Startup.cs 中 public class Startup { public Startup(IHostingE ...

  3. ASP.NET Core开发-读取配置文件Configuration appsettings.json

    https://www.cnblogs.com/linezero/p/Configuration.html ASP.NET Core 是如何读取配置文件,今天我们来学习. ASP.NET Core的配 ...

  4. Adding appsettings.json to a .NET Core console app

    This is something that strangely doesn’t seem to be that well documented and took me a while to figu ...

  5. 如何在.Net Core 2.0 App中读取appsettings.json

    This is something that strangely doesn’t seem to be that well documented and took me a while to figu ...

  6. [转]Setting the NLog database connection string in the ASP.NET Core appsettings.json

    本文转自:https://damienbod.com/2016/09/22/setting-the-nlog-database-connection-string-in-the-asp-net-cor ...

  7. IT咨询顾问:一次吐血的项目救火 java或判断优化小技巧 asp.net core Session的测试使用心得 【.NET架构】BIM软件架构02:Web管控平台后台架构 NetCore入门篇:(十一)NetCore项目读取配置文件appsettings.json 使用LINQ生成Where的SQL语句 js_jquery_创建cookie有效期问题_时区问题

    IT咨询顾问:一次吐血的项目救火   年后的一个合作公司上线了一个子业务系统,对接公司内部的单点系统.我收到该公司的技术咨询:项目启动后没有规律的突然无法登录了,重新启动后,登录一断时间后又无法重新登 ...

  8. 【无私分享:ASP.NET CORE 项目实战(第六章)】读取配置文件(一) appsettings.json

    目录索引 [无私分享:ASP.NET CORE 项目实战]目录索引 简介 在我们之前的Asp.net mvc 开发中,一提到配置文件,我们不由的想到 web.config 和 app.config,在 ...

  9. appsettings.json

    appsettings.json 目录索引 [无私分享:ASP.NET CORE 项目实战]目录索引 简介 在我们之前的Asp.net mvc 开发中,一提到配置文件,我们不由的想到 web.conf ...

随机推荐

  1. win7下安装ubuntu双系统的方法及心得体会(ps:要死好几回的节奏)

    1.win7下安装ubuntu系统后,可以很好进入ubuntu系统 但是进不去win7,开机有win7选项,但是选择后不管用 方法思路:各种修复win7的mbr 我的问题是:在winpe中发现,根本看 ...

  2. sourcetree和Git的使用教程

    1.简单的用Git管理项目. 2.怎样既要开发又要处理发布出去的版本bug情况. SourceTree是一个免费的Git图形化管理工具,mac下也可以安装. 下载地址:https://www.sour ...

  3. Linux安装Qt详细步骤 亲测总结

    下载 qt-everywhere-opensource-src-4.8.4.tar.gz================准备工作====================yum install kern ...

  4. BestCoder Round #4 Miaomiao's Geometry (暴力)

    Problem Description There are N point on X-axis . Miaomiao would like to cover them ALL by using seg ...

  5. linux perf and tracer ,java Flame Graph

    http://www.brendangregg.com/flamegraphs.html http://hg.openjdk.java.net/jdk8u/jdk8u/hotspot/rev/e826 ...

  6. System.Data.SqlClient.SqlError:无法打开备份设备'D:\..\abc.bak'

    在SQL Server中备份数据库时遇到备份对于服务器“服务器名”失败. (Microsoft.SqlServer.Smo)其他信息:System.Data.SqlClient.SqlError:无法 ...

  7. java 日期获取时间戳

    SimpleDateFormat df = new SimpleDateFormat("yyyy/MM/dd hh:mm:ss");            String dateS ...

  8. 面向对象 之 [C++面试题]

    说到面向对象,大家第一反应应该就是它的三大特性:封装性.继承性和多态性.那么我们先简单的了解一下这三大特性: (1)封装性:封装,也就是把客观事物封装成抽象的类,并且类可以把自己的数据和方法只让可信的 ...

  9. tomcat架构分析(connector BIO 实现)

    出处:http://gearever.iteye.com 在tomcat架构分析(概览)中已经介绍过,connector组件是service容器中的一部分.它主要是接收,解析http请求,然后调用本s ...

  10. js中的url地址用function函数调用

    url中输入调用函数,函数中调用ajax请求