我想把我的旧mvc5项目移到mvc6.
旧代码是:
旧代码是:
public string ContentType { get { if (!string.IsNullOrEmpty(FileName)) return MimeMapping.GetMimeMapping(FileName); return null; } }
错误是
The name ‘MimeMapping’ does not exist in the current context
解决方法
以下代码应该工作:
string contentType; new FileExtensionContentTypeProvider().TryGetContentType(FileName,out contentType); return contentType ?? "application/octet-stream";