After Telerik Update from Telerik AJAX Manager v2015.1.401.45 to Telerik AJAX Manager v2020.2.512.45 can not upload files. Always error like :
[CryptographicException: The cryptographic operation has failed!]
Telerik.Web.UI.CryptoExceptionThrower.ThrowGenericCryptoException() +46
Telerik.Web.UI.CryptoExceptionThrower.ThrowIfFails(Func`1 function) +46
Telerik.Web.UI.CryptoService.CheckWhitelistTypes(Type type, String allowedCustomMetaTypes, String uploadMetaDataFullName) +116
Telerik.Web.UI.AsyncUploadHandler.GetConfiguration(String rawData) +163
Telerik.Web.UI.AsyncUploadHandler.EnsureSetup() +148
Telerik.Web.UI.AsyncUploadHandler.ProcessRequest(HttpContext context) +140
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +195
System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +50
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +73
The error is documented in the product documentation https://docs.telerik.com/devtools/aspnet-ajax/knowledge-base/asyncupload-the-cryptographic-operation-has-failed-error-after-upgrade.
Description In R1 2020, the custom metadata classes(upload configurations) whitelisting is enabled by default - Whitelist custom metadata types. If your application uses such configurations, you will need to add them to the Telerik.Upload.AllowedCustomMetaDataTypes key in the web.config.
You need to add the fully qualified name of the class, otherwise you will get a The cryptographic operation has failed! error when attempting an upload.
web.config
<appSettings>
<add key="Telerik.Upload.AllowedCustomMetaDataTypes" value="SomeNameSpace.SampleAsyncUploadConfiguration;SomeOtherNameSpace.OtherAsyncUploadConfiguration" />
</appSettings>
Other reasons for the error If adding the AllowedCustomMetaDataTypes key or not using custom configuration files do not fix the error, please ensure you have set the necessary encryption keys:
ConfigurationEncryptionKey ConfigurationHashKey Telerik.Web.UI.DialogParametersEncryptionKey, if using RadEditor dialogs
Solution The solution is to add all the custom configuration classes to the Telerik.Upload.AllowedCustomMetaDataTypes key separated by a semicolon ;. To find out the fully qualified names, you can use the following approach that lists the items in a label.
ASP.NET
<asp:Label Text="Label1" ID="Label1" runat="server" />
C#
protected void Page_Load(object sender, EventArgs e)
{
Label1.Text = typeof(MySampleAsyncUploadConfiguration).AssemblyQualifiedName.Split(',')[0];
}
For convenience, you can download the AsyncUploadGetCustomMetaDataTypes sample project implementing the suggested approach from the link below. To make it runnable, place the Telerik.Web.UI.dll assembly in the bin folder of the project.
AsyncUploadGetCustomMetaDataTypes.zip. In the project you will find two pages with two different custom handlers. As you can see, the custom handler that does not have custom configuration, does not need to have anything added to the Telerik.Upload.AllowedCustomMetaDataTypes key.