I am using ASP.NET FW 4.6.1; Microsft.AspNet.WebApi 5.2.7; EF 6.4.
I have the issue below when starting my project.
Method request.Files is not supported (please see image)
public static class WebApiConfig
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1062:Validate arguments of public methods", Justification = "<Pending>")]
public static void Register(HttpConfiguration config)
{
// Web API configuration and services
// Web API routes
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "ActionApi",
routeTemplate: "api/{controller}/{action}/{id}",
defaults: new { id = RouteParameter.Optional }
);
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
//Enable cross domain request
EnableCorsAttribute cors = new EnableCorsAttribute("*", "*", "*");
config.EnableCors(cors);
config.Filters.Add(new ErrorHandlers.AiHandleErrorAttribute());
**config.Filters.Add(new UploadFileFilterAttribute());**
config.MessageHandlers.Add(new RequestTabletMessageHandler());
config.MessageHandlers.Add(new RequestLoggingMessageHandler());
config.Services.Add(typeof(IExceptionLogger), new CustomExceptionLogger());
}
}
The reason it is not supported is because the file buffer stream has already been parsed (or parsing has started) at a previous point in the request pipeline. You should look at other filters/modules in your pipeline and see if any of them touch the files in the incoming request. You might find that simply commenting out other filters (such as ErrorHandlers.AiHandleErrorAttribute()
for example) and rerunning could be used to quickly determine which filter/module is doing the parsing. Once you have figured that out, you need to decide how you are going to handle multiple parses of the files. One option is to only use one module, another would be to buffer it into a memory stream/block of memory and have both/all modules access that copy instead. Hope this helps.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.