Reputation: 303
IsMimeMultipartContent()
IAuthenticationFilter is not available
Read Multipart
HttpContextWrapper
I am expecting to identify how can I achieve these when I am upgrading the FW4.8 to .Net6
Upvotes: 0
Views: 583
Reputation: 5114
"CS1061: ActionExecutingContext does not contain a definition for Request".
HttpContentMultipartExtensions.IsMimeMultipartContent
is used to determine whether the specified content is MIME multipart content.
In Asp.Net Core, you can check that the request is multipart/form-data using property HttpRequest.HasFormContentType:
public override void OnActionExecuting(ActionExecutingContext actionContext)
{
if (!actionContext.HttpContext.Request.HasFormContentType){}
}
You can also refer to Mathieu Renda's answer.
IAuthenticationFilter is not available.
Asp.net core doesn't contain the IAuthenticationFilter
, if you want to authenticated the user, you can refer to Brando Zhang's answer.
Error: HttpRequest does not contain a definition for Content
You can take a look at this official document: Upload files in ASP.NET Core.
And you can also refer to these two posts to solve your problem: ReadAsMultipartAsync equvialent in .NET core 2, MultipartFormDataStreamProvider for ASP.NET Core 2.
Replacement for HttpContextWrapper
The HttpContextWrapper class derives from the HttpContextBase class and serves as a wrapper for the HttpContext class. So I think it is possible to access HttpContext directly in Asp.Net Core: Access HttpContext in ASP.NET Core.
Hope this can help you.
Upvotes: 1