StaticFiles 之 FileExtensionContentTypeProvider
3 如何新增加一个下载的文件类型呢 ? 比如.aspx 这里只是举例子: 10 FileServerOptions opt = new FileServerOptions() { EnableDirectoryBrowsing = true }; 11 FileExtensionContentTypeProvider ctp = new FileExtensionContentTypeProvider(); 12 ctp.Mappings.Add(".aspx", "text / plain"); 13 opt.StaticFileOptions.ContentTypeProvider = ctp; 14 app.UseFileServer(opt); 15 下面是支持的扩展名 很多我都不知道是什么类型 哈哈。 393 public FileExtensionContentTypeProvider() 394 : this(new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase) 395 { 396 { ".323", "text/h323" }, 397 { ".3g2", "video/3gpp2" }, 398 { ".3gp2", "video/3gpp2" }, 399 { ".3gp", "video/3gpp" }, 400 { ".3gpp", "video/3gpp" }, 401 { ".aac", "audio/aac" }, 402 { ".aaf", "application/octet-stream" }, 403 { ".aca", "application/octet-stream" }, 404 { ".accdb", "application/msaccess" }, 405 { ".accde", "application/msaccess" }, 406 { ".accdt", "application/msaccess" }, 407 { ".acx", "application/internet-property-stream" }, 408 { ".adt", "audio/vnd.dlna.adts" }, 409 { ".adts", "audio/vnd.dlna.adts" }, 410 { ".afm", "application/octet-stream" }, 411 { ".ai", "application/postscript" }, 412 { ".aif", "audio/x-aiff" }, 413 { ".aifc", "audio/aiff" }, 414 { ".aiff", "audio/aiff" }, 415 { ".application", "application/x-ms-application" }, 416 { ".art", "image/x-jg" }, 417 { ".asd", "application/octet-stream" }, 418 { ".asf", "video/x-ms-asf" }, 419 { ".asi", "application/octet-stream" }, 420 { ".asm", "text/plain" }, 421 { ".asr", "video/x-ms-asf" }, 422 { ".asx", "video/x-ms-asf" }, 423 { ".atom", "application/atom+xml" }, 424 { ".au", "audio/basic" }, 425 { ".avi", "video/x-msvideo" }, 426 { ".axs", "application/olescript" }, 427 { ".bas", "text/plain" }, 428 { ".bcpio", "application/x-bcpio" }, 429 { ".bin", "application/octet-stream" }, 430 { ".bmp", "image/bmp" }, 431 { ".c", "text/plain" }, 432 { ".cab", "application/vnd.ms-cab-compressed" }, 433 { ".calx", "application/vnd.ms-office.calx" }, 434 { ".cat", "application/vnd.ms-pki.seccat" }, 435 { ".cdf", "application/x-cdf" }, 436 { ".chm", "application/octet-stream" }, 437 { ".class", "application/x-java-applet" }, 438 { ".clp", "application/x-msclip" }, 439 { ".cmx", "image/x-cmx" }, 440 { ".cnf", "text/plain" }, 441 { ".cod", "image/cis-cod" }, 442 { ".cpio", "application/x-cpio" }, 443 { ".cpp", "text/plain" }, 444 { ".crd", "application/x-mscardfile" }, 445 { ".crl", "application/pkix-crl" }, 446 { ".crt", "application/x-x509-ca-cert" }, 447 { ".csh", "application/x-csh" }, 448 { ".css", "text/css" }, 449 { ".csv", "application/octet-stream" }, 450 { ".cur", "application/octet-stream" }, 451 { ".dcr", "application/x-director" }, 452 { ".deploy", "application/octet-stream" }, 453 { ".der", "application/x-x509-ca-cert" }, 454 { ".dib", "image/bmp" }, 455 { ".dir", "application/x-director" }, 456 { ".disco", "text/xml" }, 457 { ".dlm", "text/dlm" }, 458 { ".doc", "application/msword" }, 459 { ".docm", "application/vnd.ms-word.document.macroEnabled.12" }, 460 { ".docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document" }, 461 { ".dot", "application/msword" }, 462 { ".dotm", "application/vnd.ms-word.template.macroEnabled.12" }, 463 { ".dotx", "application/vnd.openxmlformats-officedocument.wordprocessingml.template" }, 464 { ".dsp", "application/octet-stream" }, 465 { ".dtd", "text/xml" }, 466 { ".dvi", "application/x-dvi" }, 467 { ".dvr-ms", "video/x-ms-dvr" }, 468 { ".dwf", "drawing/x-dwf" }, 469 { ".dwp", "application/octet-stream" }, 470 { ".dxr", "application/x-director" }, 471 { ".eml", "message/rfc822" }, 472 { ".emz", "application/octet-stream" }, 473 { ".eot", "application/vnd.ms-fontobject" }, 474 { ".eps", "application/postscript" }, 475 { ".etx", "text/x-setext" }, 476 { ".evy", "application/envoy" }, 477 { ".fdf", "application/vnd.fdf" }, 478 { ".fif", "application/fractals" }, 479 { ".fla", "application/octet-stream" }, 480 { ".flr", "x-world/x-vrml" }, 481 { ".flv", "video/x-flv" }, 482 { ".gif", "image/gif" }, 483 { ".gtar", "application/x-gtar" }, 484 { ".gz", "application/x-gzip" }, 485 { ".h", "text/plain" }, 486 { ".hdf", "application/x-hdf" }, 487 { ".hdml", "text/x-hdml" }, 488 { ".hhc", "application/x-oleobject" }, 489 { ".hhk", "application/octet-stream" }, 490 { ".hhp", "application/octet-stream" }, 491 { ".hlp", "application/winhlp" }, 492 { ".hqx", "application/mac-binhex40" }, 493 { ".hta", "application/hta" }, 494 { ".htc", "text/x-component" }, 495 { ".htm", "text/html" }, 496 { ".html", "text/html" }, 497 { ".htt", "text/webviewhtml" }, 498 { ".hxt", "text/html" }, 499 { ".ical", "text/calendar" }, 500 { ".icalendar", "text/calendar" }, 501 { ".ico", "image/x-icon" }, 502 { ".ics", "text/calendar" }, 503 { ".ief", "image/ief" }, 504 { ".ifb", "text/calendar" }, 505 { ".iii", "application/x-iphone" }, 506 { ".inf", "application/octet-stream" }, 507 { ".ins", "application/x-internet-signup" }, 508 { ".isp", "application/x-internet-signup" }, 509 { ".IVF", "video/x-ivf" }, 510 { ".jar", "application/java-archive" }, 511 { ".java", "application/octet-stream" }, 512 { ".jck", "application/liquidmotion" }, 513 { ".jcz", "application/liquidmotion" }, 514 { ".jfif", "image/pjpeg" }, 515 { ".jpb", "application/octet-stream" }, 516 { ".jpe", "image/jpeg" }, 517 { ".jpeg", "image/jpeg" }, 518 { ".jpg", "image/jpeg" }, 519 { ".js", "application/javascript" }, 520 { ".jsx", "text/jscript" }, 521 { ".latex", "application/x-latex" }, 522 { ".lit", "application/x-ms-reader" }, 523 { ".lpk", "application/octet-stream" }, 524 { ".lsf", "video/x-la-asf" }, 525 { ".lsx", "video/x-la-asf" }, 526 { ".lzh", "application/octet-stream" }, 527 { ".m13", "application/x-msmediaview" }, 528 { ".m14", "application/x-msmediaview" }, 529 { ".m1v", "video/mpeg" }, 530 { ".m2ts", "video/vnd.dlna.mpeg-tts" }, 531 { ".m3u", "audio/x-mpegurl" }, 532 { ".m4a", "audio/mp4" }, 533 { ".m4v", "video/mp4" }, 534 { ".man", "application/x-troff-man" }, 535 { ".manifest", "application/x-ms-manifest" }, 536 { ".map", "text/plain" }, 537 { ".mdb", "application/x-msaccess" }, 538 { ".mdp", "application/octet-stream" }, 539 { ".me", "application/x-troff-me" }, 540 { ".mht", "message/rfc822" }, 541 { ".mhtml", "message/rfc822" }, 542 { ".mid", "audio/mid" }, 543 { ".midi", "audio/mid" }, 544 { ".mix", "application/octet-stream" }, 545 { ".mmf", "application/x-smaf" }, 546 { ".mno", "text/xml" }, 547 { ".mny", "application/x-msmoney" }, 548 { ".mov", "video/quicktime" }, 549 { ".movie", "video/x-sgi-movie" }, 550 { ".mp2", "video/mpeg" }, 551 { ".mp3", "audio/mpeg" }, 552 { ".mp4", "video/mp4" }, 553 { ".mp4v", "video/mp4" }, 554 { ".mpa", "video/mpeg" }, 555 { ".mpe", "video/mpeg" }, 556 { ".mpeg", "video/mpeg" }, 557 { ".mpg", "video/mpeg" }, 558 { ".mpp", "application/vnd.ms-project" }, 559 { ".mpv2", "video/mpeg" }, 560 { ".ms", "application/x-troff-ms" }, 561 { ".msi", "application/octet-stream" }, 562 { ".mso", "application/octet-stream" }, 563 { ".mvb", "application/x-msmediaview" }, 564 { ".mvc", "application/x-miva-compiled" }, 565 { ".nc", "application/x-netcdf" }, 566 { ".nsc", "video/x-ms-asf" }, 567 { ".nws", "message/rfc822" }, 568 { ".ocx", "application/octet-stream" }, 569 { ".oda", "application/oda" }, 570 { ".odc", "text/x-ms-odc" }, 571 { ".ods", "application/oleobject" }, 572 { ".oga", "audio/ogg" }, 573 { ".ogg", "video/ogg" }, 574 { ".ogv", "video/ogg" }, 575 { ".ogx", "application/ogg" }, 576 { ".one", "application/onenote" }, 577 { ".onea", "application/onenote" }, 578 { ".onetoc", "application/onenote" }, 579 { ".onetoc2", "application/onenote" }, 580 { ".onetmp", "application/onenote" }, 581 { ".onepkg", "application/onenote" }, 582 { ".osdx", "application/opensearchdescription+xml" }, 583 { ".otf", "font/otf" }, 584 { ".p10", "application/pkcs10" }, 585 { ".p12", "application/x-pkcs12" }, 586 { ".p7b", "application/x-pkcs7-certificates" }, 587 { ".p7c", "application/pkcs7-mime" }, 588 { ".p7m", "application/pkcs7-mime" }, 589 { ".p7r", "application/x-pkcs7-certreqresp" }, 590 { ".p7s", "application/pkcs7-signature" }, 591 { ".pbm", "image/x-portable-bitmap" }, 592 { ".pcx", "application/octet-stream" }, 593 { ".pcz", "application/octet-stream" }, 594 { ".pdf", "application/pdf" }, 595 { ".pfb", "application/octet-stream" }, 596 { ".pfm", "application/octet-stream" }, 597 { ".pfx", "application/x-pkcs12" }, 598 { ".pgm", "image/x-portable-graymap" }, 599 { ".pko", "application/vnd.ms-pki.pko" }, 600 { ".pma", "application/x-perfmon" }, 601 { ".pmc", "application/x-perfmon" }, 602 { ".pml", "application/x-perfmon" }, 603 { ".pmr", "application/x-perfmon" }, 604 { ".pmw", "application/x-perfmon" }, 605 { ".png", "image/png" }, 606 { ".pnm", "image/x-portable-anymap" }, 607 { ".pnz", "image/png" }, 608 { ".pot", "application/vnd.ms-powerpoint" }, 609 { ".potm", "application/vnd.ms-powerpoint.template.macroEnabled.12" }, 610 { ".potx", "application/vnd.openxmlformats-officedocument.presentationml.template" }, 611 { ".ppam", "application/vnd.ms-powerpoint.addin.macroEnabled.12" }, 612 { ".ppm", "image/x-portable-pixmap" }, 613 { ".pps", "application/vnd.ms-powerpoint" }, 614 { ".ppsm", "application/vnd.ms-powerpoint.slideshow.macroEnabled.12" }, 615 { ".ppsx", "application/vnd.openxmlformats-officedocument.presentationml.slideshow" }, 616 { ".ppt", "application/vnd.ms-powerpoint" }, 617 { ".pptm", "application/vnd.ms-powerpoint.presentation.macroEnabled.12" }, 618 { ".pptx", "application/vnd.openxmlformats-officedocument.presentationml.presentation" }, 619 { ".prf", "application/pics-rules" }, 620 { ".prm", "application/octet-stream" }, 621 { ".prx", "application/octet-stream" }, 622 { ".ps", "application/postscript" }, 623 { ".psd", "application/octet-stream" }, 624 { ".psm", "application/octet-stream" }, 625 { ".psp", "application/octet-stream" }, 626 { ".pub", "application/x-mspublisher" }, 627 { ".qt", "video/quicktime" }, 628 { ".qtl", "application/x-quicktimeplayer" }, 629 { ".qxd", "application/octet-stream" }, 630 { ".ra", "audio/x-pn-realaudio" }, 631 { ".ram", "audio/x-pn-realaudio" }, 632 { ".rar", "application/octet-stream" }, 633 { ".ras", "image/x-cmu-raster" }, 634 { ".rf", "image/vnd.rn-realflash" }, 635 { ".rgb", "image/x-rgb" }, 636 { ".rm", "application/vnd.rn-realmedia" }, 637 { ".rmi", "audio/mid" }, 638 { ".roff", "application/x-troff" }, 639 { ".rpm", "audio/x-pn-realaudio-plugin" }, 640 { ".rtf", "application/rtf" }, 641 { ".rtx", "text/richtext" }, 642 { ".scd", "application/x-msschedule" }, 643 { ".sct", "text/scriptlet" }, 644 { ".sea", "application/octet-stream" }, 645 { ".setpay", "application/set-payment-initiation" }, 646 { ".setreg", "application/set-registration-initiation" }, 647 { ".sgml", "text/sgml" }, 648 { ".sh", "application/x-sh" }, 649 { ".shar", "application/x-shar" }, 650 { ".sit", "application/x-stuffit" }, 651 { ".sldm", "application/vnd.ms-powerpoint.slide.macroEnabled.12" }, 652 { ".sldx", "application/vnd.openxmlformats-officedocument.presentationml.slide" }, 653 { ".smd", "audio/x-smd" }, 654 { ".smi", "application/octet-stream" }, 655 { ".smx", "audio/x-smd" }, 656 { ".smz", "audio/x-smd" }, 657 { ".snd", "audio/basic" }, 658 { ".snp", "application/octet-stream" }, 659 { ".spc", "application/x-pkcs7-certificates" }, 660 { ".spl", "application/futuresplash" }, 661 { ".spx", "audio/ogg" }, 662 { ".src", "application/x-wais-source" }, 663 { ".ssm", "application/streamingmedia" }, 664 { ".sst", "application/vnd.ms-pki.certstore" }, 665 { ".stl", "application/vnd.ms-pki.stl" }, 666 { ".sv4cpio", "application/x-sv4cpio" }, 667 { ".sv4crc", "application/x-sv4crc" }, 668 { ".svg", "image/svg+xml" }, 669 { ".svgz", "image/svg+xml" }, 670 { ".swf", "application/x-shockwave-flash" }, 671 { ".t", "application/x-troff" }, 672 { ".tar", "application/x-tar" }, 673 { ".tcl", "application/x-tcl" }, 674 { ".tex", "application/x-tex" }, 675 { ".texi", "application/x-texinfo" }, 676 { ".texinfo", "application/x-texinfo" }, 677 { ".tgz", "application/x-compressed" }, 678 { ".thmx", "application/vnd.ms-officetheme" }, 679 { ".thn", "application/octet-stream" }, 680 { ".tif", "image/tiff" }, 681 { ".tiff", "image/tiff" }, 682 { ".toc", "application/octet-stream" }, 683 { ".tr", "application/x-troff" }, 684 { ".trm", "application/x-msterminal" }, 685 { ".ts", "video/vnd.dlna.mpeg-tts" }, 686 { ".tsv", "text/tab-separated-values" }, 687 { ".ttf", "application/octet-stream" }, 688 { ".tts", "video/vnd.dlna.mpeg-tts" }, 689 { ".txt", "text/plain" }, 690 { ".u32", "application/octet-stream" }, 691 { ".uls", "text/iuls" }, 692 { ".ustar", "application/x-ustar" }, 693 { ".vbs", "text/vbscript" }, 694 { ".vcf", "text/x-vcard" }, 695 { ".vcs", "text/plain" }, 696 { ".vdx", "application/vnd.ms-visio.viewer" }, 697 { ".vml", "text/xml" }, 698 { ".vsd", "application/vnd.visio" }, 699 { ".vss", "application/vnd.visio" }, 700 { ".vst", "application/vnd.visio" }, 701 { ".vsto", "application/x-ms-vsto" }, 702 { ".vsw", "application/vnd.visio" }, 703 { ".vsx", "application/vnd.visio" }, 704 { ".vtx", "application/vnd.visio" }, 705 { ".wav", "audio/wav" }, 706 { ".wax", "audio/x-ms-wax" }, 707 { ".wbmp", "image/vnd.wap.wbmp" }, 708 { ".wcm", "application/vnd.ms-works" }, 709 { ".wdb", "application/vnd.ms-works" }, 710 { ".webm", "video/webm" }, 711 { ".wks", "application/vnd.ms-works" }, 712 { ".wm", "video/x-ms-wm" }, 713 { ".wma", "audio/x-ms-wma" }, 714 { ".wmd", "application/x-ms-wmd" }, 715 { ".wmf", "application/x-msmetafile" }, 716 { ".wml", "text/vnd.wap.wml" }, 717 { ".wmlc", "application/vnd.wap.wmlc" }, 718 { ".wmls", "text/vnd.wap.wmlscript" }, 719 { ".wmlsc", "application/vnd.wap.wmlscriptc" }, 720 { ".wmp", "video/x-ms-wmp" }, 721 { ".wmv", "video/x-ms-wmv" }, 722 { ".wmx", "video/x-ms-wmx" }, 723 { ".wmz", "application/x-ms-wmz" }, 724 { ".woff", "application/font-woff" }, 725 { ".wps", "application/vnd.ms-works" }, 726 { ".wri", "application/x-mswrite" }, 727 { ".wrl", "x-world/x-vrml" }, 728 { ".wrz", "x-world/x-vrml" }, 729 { ".wsdl", "text/xml" }, 730 { ".wtv", "video/x-ms-wtv" }, 731 { ".wvx", "video/x-ms-wvx" }, 732 { ".x", "application/directx" }, 733 { ".xaf", "x-world/x-vrml" }, 734 { ".xaml", "application/xaml+xml" }, 735 { ".xap", "application/x-silverlight-app" }, 736 { ".xbap", "application/x-ms-xbap" }, 737 { ".xbm", "image/x-xbitmap" }, 738 { ".xdr", "text/plain" }, 739 { ".xht", "application/xhtml+xml" }, 740 { ".xhtml", "application/xhtml+xml" }, 741 { ".xla", "application/vnd.ms-excel" }, 742 { ".xlam", "application/vnd.ms-excel.addin.macroEnabled.12" }, 743 { ".xlc", "application/vnd.ms-excel" }, 744 { ".xlm", "application/vnd.ms-excel" }, 745 { ".xls", "application/vnd.ms-excel" }, 746 { ".xlsb", "application/vnd.ms-excel.sheet.binary.macroEnabled.12" }, 747 { ".xlsm", "application/vnd.ms-excel.sheet.macroEnabled.12" }, 748 { ".xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" }, 749 { ".xlt", "application/vnd.ms-excel" }, 750 { ".xltm", "application/vnd.ms-excel.template.macroEnabled.12" }, 751 { ".xltx", "application/vnd.openxmlformats-officedocument.spreadsheetml.template" }, 752 { ".xlw", "application/vnd.ms-excel" }, 753 { ".xml", "text/xml" }, 754 { ".xof", "x-world/x-vrml" }, 755 { ".xpm", "image/x-xpixmap" }, 756 { ".xps", "application/vnd.ms-xpsdocument" }, 757 { ".xsd", "text/xml" }, 758 { ".xsf", "text/xml" }, 759 { ".xsl", "text/xml" }, 760 { ".xslt", "text/xml" }, 761 { ".xsn", "application/octet-stream" }, 762 { ".xtp", "application/octet-stream" }, 763 { ".xwd", "image/x-xwindowdump" }, 764 { ".z", "application/x-compress" }, 765 { ".zip", "application/x-zip-compressed" }, 766 }) 767 { 768 }