GithubHelp home page GithubHelp logo

Comments (3)

twsouthwick avatar twsouthwick commented on August 11, 2024

Some APIs that may be related here:

  • HttpContext.GetSection
  • HttpContext.GetGlobalResourceObject
  • HttpContext.GetLocalResourceObject

from systemweb-adapters.

twsouthwick avatar twsouthwick commented on August 11, 2024

While thinking about this some more, I realized an additional challenge. Users will most likely be using System.Configuration.ConfigurationManager.AppSettings to grab the values throughout the code. This makes anything to use Microsoft.Extensions.Configuration more work in the migration process and potentially difficult to update all the code.

In order to help, we may want to initially ensure that the values from web.config show up in AppSettings - this moves the migration for configuration after they have successfully moved to core. I have a prototype of this in https://github.com/dotnet/systemweb-adapters/tree/tasou/web-config that adds some msbuild logic. This is needed because web.config as-is from a framework application will have configuration sections that are unknown to .NET Core which will cause a runtime exception. To mitigate this, the prototype does the following:

  • When adding Microsoft.AspNetCore.SystemWebAdapters.CoreServices, some msbuild targets will be injected into their project
  • These tasks search for any web.config entries
  • An XSL transformation is performed on the supplied web.config that will keep just the AppSettings/ConnectionStrings
  • The final web.config is placed next to the output with the name of [ProjectName].dll.config so that the configuration manager will pick it up.

Some open questions:

  • ConfigurationManager only appears to read the settings automatically if the name is [ProjectName].[exe|dll|.config. If that's the case, we may need to merge with any existing config
  • We'd probably want to help people move off of it - maybe adding an analyzer that flags usage of ConfigruationManager.[AppSettings|ConnectionStrings] and pushes people to the optinos pattern

from systemweb-adapters.

joperezr avatar joperezr commented on August 11, 2024

We talked about this one today to see if it should be considered. It is unclear if a) this problem is common enough were we want to provide a solution, and b) if this is the right approach to addressing this as opposed to having aspnetcore be able to understand web.config. @twsouthwick will follow up on this.

from systemweb-adapters.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.