当我尝试从请求中读取多部分内容时说一个内容可能已被另一个组件读取的时候,我遇到异常。
if (MultipartRequestHelper.IsMultipartContentType(Request.ContentType))
{
// Used to accumulate all the form url encoded key value pairs in the
// request.
var formAccumulator = new KeyValueAccumulator();
var boundary = Request.GetMultipartBoundary();
var reader = new MultipartReader(boundary, HttpContext.Request.Body);
var section = await reader.ReadNextSectionAsync();
while (section != null)
{
ContentDispositionHeaderValue contentDisposition;
var hasContentDispositionHeader =
ContentDispositionHeaderValue.TryParse(section.ContentDisposition, out contentDisposition);
}
}
参考方案
在asp.net core 3中,必须将factories.RemoveType<FormFileValueProviderFactory>();
添加到DisableFormValueModelBindingAttribute
属性。
码
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)]
public class DisableFormValueModelBindingAttribute : Attribute, IResourceFilter
{
public void OnResourceExecuting(ResourceExecutingContext context)
{
var factories = context.ValueProviderFactories;
factories.RemoveType<FormValueProviderFactory>();
factories.RemoveType<FormFileValueProviderFactory>();
factories.RemoveType<JQueryFormValueProviderFactory>();
}
public void OnResourceExecuted(ResourceExecutedContext context)
{
}
}
Documentation
Microsoft Excel 2010和Python中的受保护视图 - python这里没有代码示例。刚遇到Microsoft Excel 2010的问题,我在linux上有一个python脚本,可从csv文件中提取数据,将数据推送到excel,然后将该文件作为附件通过电子邮件发送到特定的电子邮件地址。我的问题是我在excel文件中使用公式,并且在它第一次打开时进入“ Protected View”。在单击“启用编辑”后,我的公式才会加载。…
Microsoft WPF转换器 - c#因此,我今天在MSDN上找到了list转换器,现在我想使用其中的一些。但是,经过一番搜索,我似乎找不到任何有关它们的信息。我主要想使用IntToBoolConverter。但是我不知道如何使用转换,因为没有信息提供如何做到这一点(或在谷歌上)。我知道自己制作这个转换器很容易,但是我是一名程序员,当可以的时候,我的moto是懒惰的,而使已经存在的方法(转换器)…
Microsoft chatbot(Node.js和C#)是否支持中英文微信集成? - c#我有一个聊天机器人,它是用Node.js在Microsoft机器人框架中构建的,并且还将该机器人与一个名为LUIS.AI的NLP框架集成在一起。我正在将其与Skype和Messenger集成,并且还尝试将其与微信集成。我正在尝试使用以下链接进行微信集成,但目前尚无法实现。https://github.com/jyfcrw/botbuilder-wechat-…
问题与连接到MSSQL数据库的Java应用程序中的com.microsoft.sqlserver.jdbc.SQLServerException - java我收到以下错误:com.microsoft.sqlserver.jdbc.SQLServerException: The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption. Error: …
ASP.NET Core-在Singleton注入上存储库依赖项注入失败 - c#我正在使用SoapCore为我的ASP.NET Core MVC应用程序创建Web服务。我正在使用Entity Framework Core和简单的存储库模式来获取我的数据库数据。我通过Startup.cs中的.AddSingleton()注入存储库类:services.AddSingleton<IImportRepository, ImportRep…