Please check the order of registering MVC service and DataProtection service. Registering DataProtection service must be before registering MVC service. Code below is for your reference.
// Add DataProtection Service
if (storageUrl != null && sasToken != null && containerName != null && applicationName != null && blobName != null)
{
// Create the new Storage URI
Uri storageUri = new Uri($"{storageUrl}{sasToken}");
//Create the blob client object.
CloudBlobClient blobClient = new CloudBlobClient(storageUri);
//Get a reference to a container to use for the sample code, and create it if it does not exist.
CloudBlobContainer container = blobClient.GetContainerReference(containerName);
container.CreateIfNotExists();
services.AddDataProtection()
.SetApplicationName(applicationName)
.PersistKeysToAzureBlobStorage(container, blobName);
}
// Add framework services.
services.AddMvc();
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…