I'm trying to move my old mvc5 project to asp net core. Old code was:
public string ContentType { get { if (!string.IsNullOrEmpty(FileName)) return MimeMapping.GetMimeMapping(FileName); return null; } }
Error is
The name 'MimeMapping' does not exist in the current context
The following code should work:
string contentType; new FileExtensionContentTypeProvider().TryGetContentType(FileName, out contentType); return contentType ?? "application/octet-stream";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With