当web.config不存在时,将条目添加到asp.net核心应用程序的web.config文件中 [英] Add entries to web.config file of asp.net core application when web.config does not exist

查看:100
本文介绍了当web.config不存在时,将条目添加到asp.net核心应用程序的web.config文件中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个针对.NET Framework 4.71的asp.net CORE项目

I have an asp.net CORE project targeting .NET Framework 4.71

有一个appsettings.json文件,但没有web.config.

There is an appsettings.json file but not web.config.

当我检查已部署的应用程序服务的二进制文件时,我看到有

When I check the binaries of the deployed application service, then I see there is

一个名叫web.config的文件.

a file literally called web.config.

我需要在该web.config中放置一些服务器标头删除条目,但看来

I need to put some server header removal entries in that web.config but it seems

仅在部署位置可用.

那么谁在创建那个在

代码解决方案?

推荐答案

在常规.NET世界中,我们可以选择将设置保存在web.config或app.config文件中.但是在.NET Core中,您可以选择将它们保存在其他几个位置,例如appsettings.jsonappsettings.<Environment>.jsonsecrets.json中.

In regular .NET world, we have option to save settings in web.config or in app.config file. But in .NET Core, you have option to save them in few other locations like appsettings.json , appsettings.<Environment>.json and in secrets.json.

未将设置保存在web.config文件中的主要原因之一是为了避免将设置检入到回购中.默认情况下,appsettings.json文件被回购客户端忽略.

One of the main reason settings are not saved in web.config file is, to avoid settings getting checked-into repo. By default appsettings.json file are ignored by repo clients.

正如柯克所说, dotnet -cli 根据csproj设置自动创建此web.config.

As Kirk said, the dotnet-cli automatically creates this web.config based on the the csproj settings.

这篇关于当web.config不存在时,将条目添加到asp.net核心应用程序的web.config文件中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆