第一步:新建文件 CustomerFileExtensionContentTypeProvider

namespace xxx
{
public class CustomerFileExtensionContentTypeProvider : FileExtensionContentTypeProvider
{
public CustomerFileExtensionContentTypeProvider() :
base((IDictionary<string, string>) new Dictionary<string, string>(
(IEqualityComparer<string>) StringComparer.OrdinalIgnoreCase)
{
{
".323",
"text/h323"
},
{
".3g2",
"video/3gpp2"
},
{
".3gp2",
"video/3gpp2"
},
{
".3gp",
"video/3gpp"
},
{
".3gpp",
"video/3gpp"
},
{
".aac",
"audio/aac"
},
{
".aaf",
"application/octet-stream"
},
{
".aca",
"application/octet-stream"
},
{
".accdb",
"application/msaccess"
},
{
".accde",
"application/msaccess"
},
{
".accdt",
"application/msaccess"
},
{
".acx",
"application/internet-property-stream"
},
{
".adt",
"audio/vnd.dlna.adts"
},
{
".adts",
"audio/vnd.dlna.adts"
},
{
".afm",
"application/octet-stream"
},
{
".ai",
"application/postscript"
},
{
".aif",
"audio/x-aiff"
},
{
".aifc",
"audio/aiff"
},
{
".aiff",
"audio/aiff"
},
{
".appcache",
"text/cache-manifest"
},
{
".application",
"application/x-ms-application"
},
{
".art",
"image/x-jg"
},
{
".asd",
"application/octet-stream"
},
{
".asf",
"video/x-ms-asf"
},
{
".asi",
"application/octet-stream"
},
{
".asm",
"text/plain"
},
{
".asr",
"video/x-ms-asf"
},
{
".asx",
"video/x-ms-asf"
},
{
".atom",
"application/atom+xml"
},
{
".au",
"audio/basic"
},
{
".avi",
"video/x-msvideo"
},
{
".axs",
"application/olescript"
},
{
".bas",
"text/plain"
},
{
".bcpio",
"application/x-bcpio"
},
{
".bin",
"application/octet-stream"
},
{
".bmp",
"image/bmp"
},
{
".c",
"text/plain"
},
{
".cab",
"application/vnd.ms-cab-compressed"
},
{
".calx",
"application/vnd.ms-office.calx"
},
{
".cat",
"application/vnd.ms-pki.seccat"
},
{
".cdf",
"application/x-cdf"
},
{
".chm",
"application/octet-stream"
},
{
".class",
"application/x-java-applet"
},
{
".clp",
"application/x-msclip"
},
{
".cmx",
"image/x-cmx"
},
{
".cnf",
"text/plain"
},
{
".cod",
"image/cis-cod"
},
{
".cpio",
"application/x-cpio"
},
{
".cpp",
"text/plain"
},
{
".crd",
"application/x-mscardfile"
},
{
".crl",
"application/pkix-crl"
},
{
".crt",
"application/x-x509-ca-cert"
},
{
".csh",
"application/x-csh"
},
{
".css",
"text/css"
},
{
".csv",
"application/octet-stream"
},
{
".cur",
"application/octet-stream"
},
{
".dcr",
"application/x-director"
},
{
".deploy",
"application/octet-stream"
},
{
".der",
"application/x-x509-ca-cert"
},
{
".dib",
"image/bmp"
},
{
".dir",
"application/x-director"
},
{
".disco",
"text/xml"
},
{
".dlm",
"text/dlm"
},
{
".doc",
"application/msword"
},
{
".docm",
"application/vnd.ms-word.document.macroEnabled.12"
},
{
".docx",
"application/vnd.openxmlformats-officedocument.wordprocessingml.document"
},
{
".dot",
"application/msword"
},
{
".dotm",
"application/vnd.ms-word.template.macroEnabled.12"
},
{
".dotx",
"application/vnd.openxmlformats-officedocument.wordprocessingml.template"
},
{
".dsp",
"application/octet-stream"
},
{
".dtd",
"text/xml"
},
{
".dvi",
"application/x-dvi"
},
{
".dvr-ms",
"video/x-ms-dvr"
},
{
".dwf",
"drawing/x-dwf"
},
{
".dwp",
"application/octet-stream"
},
{
".dxr",
"application/x-director"
},
{
".eml",
"message/rfc822"
},
{
".emz",
"application/octet-stream"
},
{
".eot",
"application/vnd.ms-fontobject"
},
{
".eps",
"application/postscript"
},
{
".etx",
"text/x-setext"
},
{
".evy",
"application/envoy"
},
{
".fdf",
"application/vnd.fdf"
},
{
".fif",
"application/fractals"
},
{
".fla",
"application/octet-stream"
},
{
".flr",
"x-world/x-vrml"
},
{
".flv",
"video/x-flv"
},
{
".gif",
"image/gif"
},
{
".gtar",
"application/x-gtar"
},
{
".gz",
"application/x-gzip"
},
{
".h",
"text/plain"
},
{
".hdf",
"application/x-hdf"
},
{
".hdml",
"text/x-hdml"
},
{
".hhc",
"application/x-oleobject"
},
{
".hhk",
"application/octet-stream"
},
{
".hhp",
"application/octet-stream"
},
{
".hlp",
"application/winhlp"
},
{
".hqx",
"application/mac-binhex40"
},
{
".hta",
"application/hta"
},
{
".htc",
"text/x-component"
},
{
".htm",
"text/html"
},
{
".html",
"text/html"
},
{
".htt",
"text/webviewhtml"
},
{
".hxt",
"text/html"
},
{
".ical",
"text/calendar"
},
{
".icalendar",
"text/calendar"
},
{
".ico",
"image/x-icon"
},
{
".ics",
"text/calendar"
},
{
".ief",
"image/ief"
},
{
".ifb",
"text/calendar"
},
{
".iii",
"application/x-iphone"
},
{
".inf",
"application/octet-stream"
},
{
".ins",
"application/x-internet-signup"
},
{
".isp",
"application/x-internet-signup"
},
{
".IVF",
"video/x-ivf"
},
{
".jar",
"application/java-archive"
},
{
".java",
"application/octet-stream"
},
{
".jck",
"application/liquidmotion"
},
{
".jcz",
"application/liquidmotion"
},
{
".jfif",
"image/pjpeg"
},
{
".jpb",
"application/octet-stream"
},
{
".jpe",
"image/jpeg"
},
{
".jpeg",
"image/jpeg"
},
{
".jpg",
"image/jpeg"
},
{
".js",
"application/javascript"
},
{
".json",
"application/json"
},
{
".jsx",
"text/jscript"
},
{
".latex",
"application/x-latex"
},
{
".lit",
"application/x-ms-reader"
},
{
".lpk",
"application/octet-stream"
},
{
".lsf",
"video/x-la-asf"
},
{
".lsx",
"video/x-la-asf"
},
{
".lzh",
"application/octet-stream"
},
{
".m13",
"application/x-msmediaview"
},
{
".m14",
"application/x-msmediaview"
},
{
".m1v",
"video/mpeg"
},
{
".m2ts",
"video/vnd.dlna.mpeg-tts"
},
{
".m3u",
"audio/x-mpegurl"
},
{
".m4a",
"audio/mp4"
},
{
".m4v",
"video/mp4"
},
{
".man",
"application/x-troff-man"
},
{
".manifest",
"application/x-ms-manifest"
},
{
".map",
"text/plain"
},
{
".markdown",
"text/markdown"
},
{
".md",
"text/markdown"
},
{
".mdb",
"application/x-msaccess"
},
{
".mdp",
"application/octet-stream"
},
{
".me",
"application/x-troff-me"
},
{
".mht",
"message/rfc822"
},
{
".mhtml",
"message/rfc822"
},
{
".mid",
"audio/mid"
},
{
".midi",
"audio/mid"
},
{
".mix",
"application/octet-stream"
},
{
".mmf",
"application/x-smaf"
},
{
".mno",
"text/xml"
},
{
".mny",
"application/x-msmoney"
},
{
".mov",
"video/quicktime"
},
{
".movie",
"video/x-sgi-movie"
},
{
".mp2",
"video/mpeg"
},
{
".mp3",
"audio/mpeg"
},
{
".mp4",
"video/mp4"
},
{
".mp4v",
"video/mp4"
},
{
".mpa",
"video/mpeg"
},
{
".mpe",
"video/mpeg"
},
{
".mpeg",
"video/mpeg"
},
{
".mpg",
"video/mpeg"
},
{
".mpp",
"application/vnd.ms-project"
},
{
".mpv2",
"video/mpeg"
},
{
".ms",
"application/x-troff-ms"
},
{
".msi",
"application/octet-stream"
},
{
".mso",
"application/octet-stream"
},
{
".mvb",
"application/x-msmediaview"
},
{
".mvc",
"application/x-miva-compiled"
},
{
".nc",
"application/x-netcdf"
},
{
".nsc",
"video/x-ms-asf"
},
{
".nws",
"message/rfc822"
},
{
".ocx",
"application/octet-stream"
},
{
".oda",
"application/oda"
},
{
".odc",
"text/x-ms-odc"
},
{
".ods",
"application/oleobject"
},
{
".oga",
"audio/ogg"
},
{
".ogg",
"video/ogg"
},
{
".ogv",
"video/ogg"
},
{
".ogx",
"application/ogg"
},
{
".one",
"application/onenote"
},
{
".onea",
"application/onenote"
},
{
".onetoc",
"application/onenote"
},
{
".onetoc2",
"application/onenote"
},
{
".onetmp",
"application/onenote"
},
{
".onepkg",
"application/onenote"
},
{
".osdx",
"application/opensearchdescription+xml"
},
{
".otf",
"font/otf"
},
{
".p10",
"application/pkcs10"
},
{
".p12",
"application/x-pkcs12"
},
{
".p7b",
"application/x-pkcs7-certificates"
},
{
".p7c",
"application/pkcs7-mime"
},
{
".p7m",
"application/pkcs7-mime"
},
{
".p7r",
"application/x-pkcs7-certreqresp"
},
{
".p7s",
"application/pkcs7-signature"
},
{
".pbm",
"image/x-portable-bitmap"
},
{
".pcx",
"application/octet-stream"
},
{
".pcz",
"application/octet-stream"
},
{
".pdf",
"application/pdf"
},
{
".pfb",
"application/octet-stream"
},
{
".pfm",
"application/octet-stream"
},
{
".pfx",
"application/x-pkcs12"
},
{
".pgm",
"image/x-portable-graymap"
},
{
".pko",
"application/vnd.ms-pki.pko"
},
{
".pma",
"application/x-perfmon"
},
{
".pmc",
"application/x-perfmon"
},
{
".pml",
"application/x-perfmon"
},
{
".pmr",
"application/x-perfmon"
},
{
".pmw",
"application/x-perfmon"
},
{
".png",
"image/png"
},
{
".pnm",
"image/x-portable-anymap"
},
{
".pnz",
"image/png"
},
{
".pot",
"application/vnd.ms-powerpoint"
},
{
".potm",
"application/vnd.ms-powerpoint.template.macroEnabled.12"
},
{
".potx",
"application/vnd.openxmlformats-officedocument.presentationml.template"
},
{
".ppam",
"application/vnd.ms-powerpoint.addin.macroEnabled.12"
},
{
".ppm",
"image/x-portable-pixmap"
},
{
".pps",
"application/vnd.ms-powerpoint"
},
{
".ppsm",
"application/vnd.ms-powerpoint.slideshow.macroEnabled.12"
},
{
".ppsx",
"application/vnd.openxmlformats-officedocument.presentationml.slideshow"
},
{
".ppt",
"application/vnd.ms-powerpoint"
},
{
".pptm",
"application/vnd.ms-powerpoint.presentation.macroEnabled.12"
},
{
".pptx",
"application/vnd.openxmlformats-officedocument.presentationml.presentation"
},
{
".prf",
"application/pics-rules"
},
{
".prm",
"application/octet-stream"
},
{
".prx",
"application/octet-stream"
},
{
".ps",
"application/postscript"
},
{
".psd",
"application/octet-stream"
},
{
".psm",
"application/octet-stream"
},
{
".psp",
"application/octet-stream"
},
{
".pub",
"application/x-mspublisher"
},
{
".qt",
"video/quicktime"
},
{
".qtl",
"application/x-quicktimeplayer"
},
{
".qxd",
"application/octet-stream"
},
{
".ra",
"audio/x-pn-realaudio"
},
{
".ram",
"audio/x-pn-realaudio"
},
{
".rar",
"application/octet-stream"
},
{
".ras",
"image/x-cmu-raster"
},
{
".rf",
"image/vnd.rn-realflash"
},
{
".rgb",
"image/x-rgb"
},
{
".rm",
"application/vnd.rn-realmedia"
},
{
".rmi",
"audio/mid"
},
{
".roff",
"application/x-troff"
},
{
".rpm",
"audio/x-pn-realaudio-plugin"
},
{
".rtf",
"application/rtf"
},
{
".rtx",
"text/richtext"
},
{
".scd",
"application/x-msschedule"
},
{
".sct",
"text/scriptlet"
},
{
".sea",
"application/octet-stream"
},
{
".setpay",
"application/set-payment-initiation"
},
{
".setreg",
"application/set-registration-initiation"
},
{
".sgml",
"text/sgml"
},
{
".sh",
"application/x-sh"
},
{
".shar",
"application/x-shar"
},
{
".sit",
"application/x-stuffit"
},
{
".sldm",
"application/vnd.ms-powerpoint.slide.macroEnabled.12"
},
{
".sldx",
"application/vnd.openxmlformats-officedocument.presentationml.slide"
},
{
".smd",
"audio/x-smd"
},
{
".smi",
"application/octet-stream"
},
{
".smx",
"audio/x-smd"
},
{
".smz",
"audio/x-smd"
},
{
".snd",
"audio/basic"
},
{
".snp",
"application/octet-stream"
},
{
".spc",
"application/x-pkcs7-certificates"
},
{
".spl",
"application/futuresplash"
},
{
".spx",
"audio/ogg"
},
{
".src",
"application/x-wais-source"
},
{
".ssm",
"application/streamingmedia"
},
{
".sst",
"application/vnd.ms-pki.certstore"
},
{
".stl",
"application/vnd.ms-pki.stl"
},
{
".sv4cpio",
"application/x-sv4cpio"
},
{
".sv4crc",
"application/x-sv4crc"
},
{
".svg",
"image/svg+xml"
},
{
".svgz",
"image/svg+xml"
},
{
".swf",
"application/x-shockwave-flash"
},
{
".t",
"application/x-troff"
},
{
".tar",
"application/x-tar"
},
{
".tcl",
"application/x-tcl"
},
{
".tex",
"application/x-tex"
},
{
".texi",
"application/x-texinfo"
},
{
".texinfo",
"application/x-texinfo"
},
{
".tgz",
"application/x-compressed"
},
{
".thmx",
"application/vnd.ms-officetheme"
},
{
".thn",
"application/octet-stream"
},
{
".tif",
"image/tiff"
},
{
".tiff",
"image/tiff"
},
{
".toc",
"application/octet-stream"
},
{
".tr",
"application/x-troff"
},
{
".trm",
"application/x-msterminal"
},
{
".ts",
"video/vnd.dlna.mpeg-tts"
},
{
".tsv",
"text/tab-separated-values"
},
{
".ttc",
"application/x-font-ttf"
},
{
".ttf",
"application/x-font-ttf"
},
{
".tts",
"video/vnd.dlna.mpeg-tts"
},
{
".txt",
"text/plain"
},
{
".u32",
"application/octet-stream"
},
{
".uls",
"text/iuls"
},
{
".ustar",
"application/x-ustar"
},
{
".vbs",
"text/vbscript"
},
{
".vcf",
"text/x-vcard"
},
{
".vcs",
"text/plain"
},
{
".vdx",
"application/vnd.ms-visio.viewer"
},
{
".vml",
"text/xml"
},
{
".vsd",
"application/vnd.visio"
},
{
".vss",
"application/vnd.visio"
},
{
".vst",
"application/vnd.visio"
},
{
".vsto",
"application/x-ms-vsto"
},
{
".vsw",
"application/vnd.visio"
},
{
".vsx",
"application/vnd.visio"
},
{
".vtx",
"application/vnd.visio"
},
{
".wasm",
"application/wasm"
},
{
".wav",
"audio/wav"
},
{
".wax",
"audio/x-ms-wax"
},
{
".wbmp",
"image/vnd.wap.wbmp"
},
{
".wcm",
"application/vnd.ms-works"
},
{
".wdb",
"application/vnd.ms-works"
},
{
".webm",
"video/webm"
},
{
".webp",
"image/webp"
},
{
".wks",
"application/vnd.ms-works"
},
{
".wm",
"video/x-ms-wm"
},
{
".wma",
"audio/x-ms-wma"
},
{
".wmd",
"application/x-ms-wmd"
},
{
".wmf",
"application/x-msmetafile"
},
{
".wml",
"text/vnd.wap.wml"
},
{
".wmlc",
"application/vnd.wap.wmlc"
},
{
".wmls",
"text/vnd.wap.wmlscript"
},
{
".wmlsc",
"application/vnd.wap.wmlscriptc"
},
{
".wmp",
"video/x-ms-wmp"
},
{
".wmv",
"video/x-ms-wmv"
},
{
".wmx",
"video/x-ms-wmx"
},
{
".wmz",
"application/x-ms-wmz"
},
{
".woff",
"application/font-woff"
},
{
".woff2",
"font/woff2"
},
{
".wps",
"application/vnd.ms-works"
},
{
".wri",
"application/x-mswrite"
},
{
".wrl",
"x-world/x-vrml"
},
{
".wrz",
"x-world/x-vrml"
},
{
".wsdl",
"text/xml"
},
{
".wtv",
"video/x-ms-wtv"
},
{
".wvx",
"video/x-ms-wvx"
},
{
".x",
"application/directx"
},
{
".xaf",
"x-world/x-vrml"
},
{
".xaml",
"application/xaml+xml"
},
{
".xap",
"application/x-silverlight-app"
},
{
".xbap",
"application/x-ms-xbap"
},
{
".xbm",
"image/x-xbitmap"
},
{
".xdr",
"text/plain"
},
{
".xht",
"application/xhtml+xml"
},
{
".xhtml",
"application/xhtml+xml"
},
{
".xla",
"application/vnd.ms-excel"
},
{
".xlam",
"application/vnd.ms-excel.addin.macroEnabled.12"
},
{
".xlc",
"application/vnd.ms-excel"
},
{
".xlm",
"application/vnd.ms-excel"
},
{
".xls",
"application/vnd.ms-excel"
},
{
".xlsb",
"application/vnd.ms-excel.sheet.binary.macroEnabled.12"
},
{
".xlsm",
"application/vnd.ms-excel.sheet.macroEnabled.12"
},
{
".xlsx",
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
},
{
".xlt",
"application/vnd.ms-excel"
},
{
".xltm",
"application/vnd.ms-excel.template.macroEnabled.12"
},
{
".xltx",
"application/vnd.openxmlformats-officedocument.spreadsheetml.template"
},
{
".xlw",
"application/vnd.ms-excel"
},
{
".xml",
"text/xml"
},
{
".xof",
"x-world/x-vrml"
},
{
".xpm",
"image/x-xpixmap"
},
{
".xps",
"application/vnd.ms-xpsdocument"
},
{
".xsd",
"text/xml"
},
{
".xsf",
"text/xml"
},
{
".xsl",
"text/xml"
},
{
".xslt",
"text/xml"
},
{
".xsn",
"application/octet-stream"
},
{
".xtp",
"application/octet-stream"
},
{
".xwd",
"image/x-xwindowdump"
},
{
".z",
"application/x-compress"
},
{
".zip",
"application/x-zip-compressed"
},
{
".less",
"stylesheet/css"
}
})
{
}
}
}

第二部:修改startup.cs,在Configure方法内:

app.UseStaticFiles(new StaticFileOptions
{
ContentTypeProvider = new CustomerFileExtensionContentTypeProvider()
});

【aspnetcore】让aspnetcore支持less文件的更多相关文章

  1. 让.net core 支持静态文件

    想不到默认的.net core竟然不支持静态文件,还需要额外配置中间件来支持 1.Nuget安装  Microsoft.aspnetcore.staticfiles 2.在Startup.cs中使用服 ...

  2. x:bind不支持样式文件 或 此Xaml文件必须又代码隐藏类才能使用{x:Bind} 解决办法

    这两天学习UWP开发,发现一个很有趣的问题,就是我题目中的描述的. 我习惯了在ResourceDictionary中写样式文件,但是发现用x:Bind时会有问题 如果是写在Style里,则提示 “x: ...

  3. 强大的支持多文件上传的jQuery文件上传插件Uploadify

    支持多文件上传的jQuery文件上传插件Uploadify,目前此插件有两种版本即Flash版本和HTML5版本,对于HTML5版本会比较好的支持手机浏览器,避免苹果手机Safari浏览器不支持Fla ...

  4. 表单多文件上传样式美化 && 支持选中文件后删除相关项

    开发中会经常涉及到文件上传的需求,根据业务不同的需求,有不同的文件上传情况. 有简单的单文件上传,有多文件上传,因浏览器原生的文件上传样式及功能的支持度不算太高,很多时候我们会对样式进行美化,对功能进 ...

  5. uedit修改文件上传路劲,支持api文件接口

    首先修改一个东西ueditor/ueditor.config.js serverUrl: URL + "php/controller.php" 原来 serverUrl: &quo ...

  6. 解剖SQLSERVER 第八篇 OrcaMDF 现在支持多数据文件的数据库(译)

    解剖SQLSERVER 第八篇  OrcaMDF 现在支持多数据文件的数据库(译) http://improve.dk/orcamdf-now-supports-databases-with-mult ...

  7. 如何设置让iis服务器支持.apk文件的下载

    随着智能手机的普及,越来越多的人使用手机上网,很多网站也应手机上网的需要推出了网站客户端,.apk文件就是安卓(Android)的应用程序后缀名,默认情况下,使用IIS作为Web服务器的无法下载此文件 ...

  8. 如何让你的Apache支持include文件解析和支持shtml的相关配置

    源地址:http://www.itokit.com/2011/0430/65992.html Apache支持include文件解析shtml首先要应该修改Apache配置文件httpd.conf . ...

  9. skymvc文件上传支持多文件上传

    skymvc文件上传支持多文件上传 支持单文件.多文件上传 可以设定 文件大小.存储目录.文件类型 //上传的文件目录 $this->upload->uploaddir="att ...

  10. IIS 服务器 支持.apk文件的下载

    IIS服务器不能下载.apk文件的解决办法:既然.apk无法下载是因为没有MIME,那么添加一个MIME类型就可以了 随着智能手机的普及,越来越多的人使用手机上网,很多网站也应手机上网的需要推出了网站 ...

随机推荐

  1. Gradients渐变属性

    一个很不错的网站http://www.w3schools.com/css/css3_gradients.asp http://www.w3cplus.com/css3/new-css3-linear- ...

  2. ansible操作模块相关

    1. 查看模块可用参数命令 ansible-doc -s module_name

  3. IOS开发学习笔记(2)-----UIButton 详解

    1. [代码][C/C++]代码     //这里创建一个圆角矩形的按钮    UIButton *button1 = [UIButton buttonWithType:UIButtonTypeRou ...

  4. Java 并发 —— volatile 关键字

    volatile 修饰变量等于向编译器传达如下两层含义: 保证了不同线程对这个变量进行操作时的可见性,即一个线程修改了某个变量的值,这新值对其他线程来说是立即可见的. 禁止进行指令重排序. volat ...

  5. BZOJ_3680_吊打XXX_模拟退火

    BZOJ_3680_吊打XXX_模拟退火 Description gty又虐了一场比赛,被虐的蒟蒻们决定吊打gty.gty见大势不好机智的分出了n个分身,但还是被人多势众的蒟蒻抓住了.蒟蒻们将 n个g ...

  6. Java笔记(六)

    IO流: 字符流和字节流: 字符流两个基类: InputStream OutputStream 字节流两个基类: Reader Writer FileWriter: import java.io.Fi ...

  7. [HAOI 2012] 外星人

    [题目链接] https://www.lydsy.com/JudgeOnline/problem.php?id=2749 [算法] 首先 , 每次对一个数x进行操作 , 只会使该数减少一个2的因子 那 ...

  8. 点分治 [IOI2011]Race

    BZOJ2599. 放板子.利用agc009-D 代码简洁了很多 #include <bits/stdc++.h> #define N 200005 using namespace std ...

  9. JUC类图

    JUC的类图总览.

  10. 给DataTable中添加一行数据

    一.如果该DataTable有两列,列的名称是Name,Age,且该DataTable的名称是dt; DataRow dr = dt.NewRow(); dr["Name"] = ...