telerik - Telerik AJAX 无法上传文件
问题描述
Telerik 从 Telerik AJAX Manager v2015.1.401.45 更新到 Telerik AJAX Manager v2020.2.512.45 后无法上传文件。总是像这样的错误:
[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
解决方案
说明 在 R1 2020 中,默认启用自定义元数据类(上传配置)白名单 - 白名单自定义元数据类型。如果您的应用程序使用此类配置,您需要将它们添加到 web.config 中的 Telerik.Upload.AllowedCustomMetaDataTypes 键。
需要添加类的全限定名,否则会得到一个 The cryptographic operation has failed!尝试上传时出错。
网络配置
<appSettings>
<add key="Telerik.Upload.AllowedCustomMetaDataTypes" value="SomeNameSpace.SampleAsyncUploadConfiguration;SomeOtherNameSpace.OtherAsyncUploadConfiguration" />
</appSettings>
其他错误原因 如果添加 AllowedCustomMetaDataTypes 密钥或不使用自定义配置文件无法修复错误,请确保您已设置必要的加密密钥:
ConfigurationEncryptionKey ConfigurationHashKey Telerik.Web.UI.DialogParametersEncryptionKey,如果使用 RadEditor 对话框
解决方案 解决方案是将所有自定义配置类添加到 Telerik.Upload.AllowedCustomMetaDataTypes 键中,以分号; 分隔。要找出完全限定的名称,您可以使用以下列出标签中项目的方法。
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];
}
为方便起见,您可以从下面的链接下载实施建议方法的 AsyncUploadGetCustomMetaDataTypes 示例项目。要使其可运行,请将 Telerik.Web.UI.dll 程序集放在项目的 bin 文件夹中。
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.
推荐阅读
- javascript - 使用 javascript 和 html 应用多个视口
- java - 如何将我的响应正文时间戳格式更改为 unix 时间戳?
- java - 如何在不连接到 Cassandra 的情况下创建 CassandraTableScanJavaRDD?
- ios - Apple 邀请流程已更改无法访问 developer.apple.com 中的配置文件
- javascript - 没有相对路径的动态导入模块
- linq - Entity Framework Core 是否支持联合?
- ios - 如何在 Swift 中制作弧形进度条?
- email - 如何测量电子邮件的停留时间
- php - 为什么提交表单信息时出现空白屏幕?
- javascript - 类中静态函数和普通函数的区别