dotnet/systemweb-adapters

Ask About WebConfigurationManager, ConfigurationManager, HttpRuntimeSection, MachineKeySection, AuthenticationSection, AuthorizationSection

Clounea opened this issue · 4 comments

Background

We use WebConfigurationManager and ConfigurationManager in our ASP.Net (.NetFramework) apps. Now we are migrating code to ASP.NetCore. We have met issues about missing APIs of WebConfigurationManager, ConfigurationManager, HttpRuntimeSection, MachineKeySection, AuthenticationSection and AuthorizationSection.
I know that ASP.NetCore provide ConfigurationProviders Configuration
But I don't know how to find the equivalent considering our scenario. And I don't know if there is plan to add them to systemwebadapers. If there is not a plan, or it's hard to make the equivalent an adapter, I could add the equivalent in our own repo.

Summary

I want to know if there is equivalent in .NetCore. And if there is a plan to add them to the adapter.
The detail scenarios are listed in the Examples section

  • WebConfigurationManager/ConfigurationManager.GetSection
  • HttpRuntimeSection
  • MachineKeySection
  • AuthenticationSection
  • AuthorizationSection

Motivation and goals

We need migrate code (an API in Sharepoint) to ASP.NetCore and we find that the APIs are not supported by ASP.NetCore

In scope

  • WebConfigurationManager/ConfigurationManager.GetSection
  • HttpRuntimeSection
  • MachineKeySection
  • AuthenticationSection
  • AuthorizationSection

Examples

  1. Set ScriptTimeout
 HttpRuntimeSection runtimeSection = context.GetSection("system.web/httpRuntime") as HttpRuntimeSection;
if (runtimeSection != null)
    context.Server.ScriptTimeout = (int)runtimeSection.ExecutionTimeout.TotalSeconds;
  1. Get AuthMode
AuthenticationSection authenticationSection = (AuthenticationSection)WebConfigurationManager.GetSection("system.web/authentication", "/");
var mode = authenticationSection.Mode;
  1. Set AllowAnonymous
bool AllowAnonymous = true;
AuthorizationSection authorizationSection =
        (AuthorizationSection)WebConfigurationManager.GetSection("system.web/authorization");
foreach (AuthorizationRule r in authorizationSection.Rules)
{
        if (r.Action == AuthorizationRuleAction.Deny)
        {
            AllowAnonymous = false;
            break;
        }
    }
  1. Get ValidationKey
string validationKey = string.Empty;
 MachineKeySection mksec= WebConfigurationManager.GetSection("system.web/machineKey") as MachineKeySection;
  if (mkSec != null)
 {
       validationKey = mkSec.ValidationKey;
}

These are all going to be very different from configuration in ASP.NET Core and probably out of scope here. How pervasive is this usage in your code base? It may be easier to have this be a separate code path in framework/core - potentially with your own API to manage this.

btw - do you use MachineKey type itself? I have a POC of it working in the adapters and an open issue (#324) to track adding it.

These are all going to be very different from configuration in ASP.NET Core and probably out of scope here. How pervasive is this usage in your code base? It may be easier to have this be a separate code path in framework/core - potentially with your own API to manage this.

The code is used around 20 places. I could add them in our code.

btw - do you use MachineKey type itself? I have a POC of it working in the adapters and an open issue (#324) to track adding it.

No, I don't find any usage of type MachineKey. We only use the MachineKeySection.