ASP.NET Core Web.Config publish - asp.net-core

When publishing a .Net Core app to a server via WebDeploy, a Web.Config file is created, with stdoutLogEnabled=false. This is overwriting the web.config on the server where I have set stdoutLogEnabled=true.
I struggling to find how I set the default value of stdoutLogEnabled prior to publishing. On .Net framework apps I would do this within the web.config file with transformations, however in .Net core I actually don't have a web.config file within my solution.
I've tried to find documentation on how to set the value, but it either doesn't exist, or more likely, I'm not using the correct search term. Can somebody please advise on how to set default values in the web.config.

Create a web.config and put it the root directory of your source, Modify the web.config file to enable logging and any other customization you need.
When you publish, it’ll use that file instead of generating a completely new file.

Related

Add entries to web.config file of asp.net core application when web.config does not exist

I have an asp.net CORE project targeting .NET Framework 4.71
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
a file literally called web.config.
I need to put some server header removal entries in that web.config but it seems
only to be available where it is deployed.
So who is creating that web.config file which is not available locally in the
code solution?
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.
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.
As Kirk said, the dotnet-cli automatically creates this web.config based on the the csproj settings.

Asp.net Hosted Blazor - Can i use app.config or web.config?

Im looking to add a web.config (or app.config) so that i can have different settings (e.g. DEV build vs RELEASE build, for instance).
Can i simply add a .config file and expect to read from it?
I noticed that there is also an option to add a appsettings.json (App Settings File).
Which one of these should i be using for Blazor Client app (hosted via Asp.net)?
Thanks
Updates
Based on the following thread, i might just go with a settings
file on the Server side and feeding it to the Client via API.
Here is another reference for appsettings.json vs web.config
I was able to find a more concrete example int this article.
I believe you can use appsettings.Development.json and appsettings.json
Hope this helps...

in the .net core,it has Web.config Transformation Syntax for Web Application Project Deployment?

Like this(this is asp.net web The program):
While web.config transforms are still an option, Asp.Net Core seems to be moving away from them for application-level configuration and instead using things like environment variables and config.json files.
For the JSON configuration file option, you are able to create multiple JSON files for each environment, and use an environment variable at runtime to determine which file is loaded. More information can be found here: https://learn.microsoft.com/en-us/aspnet/core/fundamentals/configuration

How do I add a web.config to an owin self-hosted web api?

I actually just created an NServiceBus self-hosted endpoint and bootstrapped owin self-hosted web api 2 by adding the Microsoft.AspNet.WebApi.OwinSelfHost nuget package. It's all up and running fine and I can hit the controller endpoints that I added, but the package didn't add the normal items like the web.config.
I'd like to have the normal web.config available to where I can also add in different build configurations (the transform files like web.debug.config, web.release.config, etc).
How do I add this into my project?
I tried just adding the file, but ConfigurationManager doesn't read it.
web.config is used for asp.net web application on a hosted server. As you are using a self-hosted server then web.config is no applicable. You would need app.config which would resolve to the executable name with the .config file extension.
Add app.config to the project and ConfigurationManager should be able to read it.
UPDATE:
It was indicated that the same config transformation was also needed for app.config
The following VS tool fills in the gap left between web.config transformations.
Configuration Transform
Automatically transform app.config or any other config during build
process. Once the transformation is set, it will run on other build
machines without the extension.
The link includes step by step instructions on how to use it in applying configuration transformations.

WebDeploy with VS2015 ignores web.config transform

I opened an existing project in VS2015, made some small changes and published the MVC application to my webserver with an existing WebDeploy publishing profile. This broke the application because the web.config file on the server was overwritten with the original one for my developers machine. I have checked the settings in the Publish-wizard but the configuration was like always before. I could fix the application by manually changing the web.config on production but am afraid now to publish again.
Has anything changed in the WebDeploy publishing method with web.config transformation?
I solved it. In my case the publishing profile was renamed to "servername (production)" and the configuration setting for the transformation was only web.servername.config. After changing the name of the publishing profile to the exact same name as the config setting it worked.