mime-types – 在ASP.NET 5中使用MimeMapping(vNext)
发布时间:2020-12-15 22:52:01 所属栏目:asp.Net 来源:网络整理
导读:我想把我的旧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 conte
我想把我的旧mvc5项目移到mvc6.
旧代码是: public string ContentType { get { if (!string.IsNullOrEmpty(FileName)) return MimeMapping.GetMimeMapping(FileName); return null; } } 错误是
解决方法
以下代码应该工作:
string contentType; new FileExtensionContentTypeProvider().TryGetContentType(FileName,out contentType); return contentType ?? "application/octet-stream"; (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- ASP.NET CodeFile,CodeBehind和Inherits
- asp.net-mvc – 防止用户在asp.net模型验证中输入表单时输入
- 自动填充 – 带下拉建议的文本框
- ASP.NET MVC中的静态文件授权与Owin
- asp.net – 在.NET 4.5中混合使用Windows和Forms身份验证:
- asp.net-mvc-4 – EF5.x中对PadLeft缺乏支持的任何解决方法
- asp.net – 依赖关系未安装在Visual Studio中
- asp.net – 静态方法的缺点是什么?
- asp.net – IQueryable和存储库 – 需要2?
- 在Entity Framework中使用存储过程(五):如何通过存储过程
推荐文章
站长推荐
热点阅读