Skip to content

Ambiguos details in provided examples in the documentation #35167

@CodersaurusRex

Description

@CodersaurusRex

Description

in the documentation, the code is given as following

using System;
using System.IO;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.AspNetCore.DataProtection.SystemWeb;
using Microsoft.Extensions.DependencyInjection;

namespace DataProtectionDemo
{
    public class MyDataProtectionStartup : DataProtectionStartup
    {
        public override void ConfigureServices(IServiceCollection services)
        {
            services.AddDataProtection()
                .SetApplicationName("my-app")
                .PersistKeysToFileSystem(new DirectoryInfo(@"\\server\share\myapp-keys\"))
                .ProtectKeysWithCertificate("thumbprint");
        }
    }
}

So here application name is my-app

Further down it says

Fill in the blank value with the assembly-qualified name of the DataProtectionStartup-derived type you just created. If the name of the application is DataProtectionDemo, this would look like the below.

<add key="aspnet:dataProtectionStartupType"
     value="DataProtectionDemo.MyDataProtectionStartup, DataProtectionDemo" />

So does DataProtectionDemo here mean the .NET application name or does it mean the name set in .SetApplicationName(<name>)

Is the application name in the appsettings config therefore meaning it should be this?

<add key="aspnet:dataProtectionStartupType"
     value="DataProtectionDemo.MyDataProtectionStartup, my-app" />

or do the examples line up and this is to be the name of the application as it is in the solution and not as specified in .SetApplicationName("my-app")

Page URL

https://learn.microsoft.com/en-us/aspnet/core/security/data-protection/compatibility/replacing-machinekey?view=aspnetcore-8.0

Content source URL

https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/security/data-protection/compatibility/replacing-machinekey.md

Document ID

53e91296-c75c-b446-1487-6710b024ad60

Platform Id

fdb81ffd-0c05-6938-35a9-be23d0217459

Article author

@Rick-Anderson

Metadata

  • ID: 3709a375-e1f3-a47a-5f91-6bed1782a594
  • PlatformId: fdb81ffd-0c05-6938-35a9-be23d0217459
  • Service: aspnet-core
  • Sub-service: security

Related Issues

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions