问:
.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. Hspice仿真打印某个子模块中所有信号信息

    简单的说就是在你要打印的子模块中加一句:.probe v(*) i(*)就可以了,这个子模块的每一个实例都会被打印出来.

  2. SQL Server 异常处理机制(Begin try Begin Catch) 摘录

    begin try --SQL end try begin catch --sql (处理出错动作) end catch 我们将可能会出错的sql 写在begin try...end try 之间,若 ...

  3. Windows Azure Mobiles Services实现client的登录注冊

    下文仅仅是简单实现,client以Android端的实现为例: 用户表Account: package com.microsoft.ecodrive.model; public class Accou ...

  4. python @property使用详解

    1.@property,@xx.setter的作用把方法变成属性@property获取属性@xx.setter设置属性 2.使用示例 #@property使用 class Lang(object): ...

  5. 转-webstorm快捷键

    默认配置-Eclipse的常用快捷键对照表 查找/代替 Webstorm快捷键 Eclipse快捷键 说明 ctrl+shift+N ctrl+shift+R 通过文件名快速查找工程内的文件(必记) ...

  6. maven引入ojdbc

    http://blog.csdn.net/linminqin/article/details/17922413 ******************************************** ...

  7. linux tail -f 和 tail -F的区别 && tail 的断点续传

    bash-1中启动如下进程while [ "true" ] ; do date >> test.log; sleep 1 ; done; bash-2中,tail -f ...

  8. java web 自定义的权限框架

    权限框架2部分 1.认证  (通常指登录) 2.授权   (指用户访问改页面是否有权限) 设计:

  9. IWDG—独立看门狗

    本章参考资料:<STM32F4XX 中文参考手册> IWDG 章节.学习本章时,配合<STM32F4XX 中文参考手册> IWDG 章节一起阅读,效果会更佳,特别是涉及到寄存器 ...

  10. dp之最长递增子序列模板poj3903

    最长递增子序列,Longest Increasing Subsequence 下面我们简记为 LIS.排序+LCS算法 以及 DP算法就忽略了,这两个太容易理解了. 假设存在一个序列d[1..9] = ...