The image cannot be displayed.
A web page displays images, but in some browsers, it displays the following:
Insus. NET guesses, either browser incompatibility or code problems.
In the Code, only the output data stream, there are many image formats, such as jpg, png, bmp, etc., are not specified, and the program is not clear about the format of the image to be displayed.
Therefore, Insus. NET changed the code to the following:
Context. response. buffer = false; FileStream inStr = null; byte [] buffer = new byte [1024]; long byteCount; inStr = File. openRead (path); while (byteCount = inStr. read (buffer, 0, buffer. length)> 0) {if (context. response. isClientConnected) {context. response. contentType = "image/png"; context. response. outputStream. write (buffer, 0, buffer. length); context. response. flush ();}}Source Code
After this change, all browsers are displayed normally:
In addition, the ContentType is attached for future reference and reference:
"Ez" => "application/andrew-inset"
"Hqx" => "application/mac-binhex40"
"Cpt" => "application/mac-compactpro"
"Doc" => "application/msword"
"Bin" => "application/octet-stream"
"Dms" => "application/octet-stream"
"Lha" => "application/octet-stream"
"Lzh" => "application/octet-stream"
"Exe" => "application/octet-stream"
"Class" => "application/octet-stream"
"So" => "application/octet-stream"
"Dll" => "application/octet-stream"
"Oda" => "application/oda"
"Pdf" => "application/pdf"
"Ai" => "application/postscript"
"Eps" => "application/postscript"
"Ps" => "application/postscript"
"Smi" => "application/smil"
"Smil" => "application/smil"
"Mif" => "application/vnd. mif"
"Xls" => "application/vnd. ms-excel"
"Ppt" => "application/vnd. ms-powerpoint"
"Wbxml" => "application/vnd. wap. wbxml"
"Wmlc" => "application/vnd. wap. wmlc"
"Wmlsc" => "application/vnd. wap. wmlscriptc"
"Bcpio" => "application/x-bcpio"
"Vcd" => "application/x-cdlink"
"Pgn" => "application/x-chess-pgn"
"Cpio" => "application/x-cpio"
"Csh" => "application/x-csh"
"Dcr" => "application/x-director"
"Dir" => "application/x-director"
"Dxr" => "application/x-director"
"Dvi" => "application/x-dvi"
"Spl" => "application/x-futuresplash"
"Gtar" => "application/x-gtar"
"Hdf" => "application/x-hdf"
"Js" => "application/x-javascript"
"Skp" => "application/x-koan"
"Skd" => "application/x-koan"
"Skt" => "application/x-koan"
"Skm" => "application/x-koan"
"Latex" => "application/x-latex"
"Nc" => "application/x-netcdf"
"Cdf" => "application/x-netcdf"
"Sh" => "application/x-sh"
"Shar" => "application/x-shar"
"Swf" => "application/x-shockwave-flash"
"Sit" => "application/x-stuffit"
"Sv4cpio" => "application/x-sv4cpio"
"Sv4crc" => "application/x-sv4crc"
"Tar" => "application/x-tar"
"Tcl" => "application/x-tcl"
"Tex" => "application/x-tex"
"Texinfo" => "application/x-texinfo"
"Texi" => "application/x-texinfo"
"T" => "application/x-troff"
"Tr" => "application/x-troff"
"Roff" => "application/x-troff"
"Man" => "application/x-troff-man"
"Me" => "application/x-troff-me"
"Ms" => "application/x-troff-ms"
"Ustar" => "application/x-ustar"
"Src" => "application/x-wais-source"
"Xhtml" => "application/xhtml + xml"
"Xht" => "application/xhtml + xml"
"Zip" => "application/zip"
"Au" => "audio/basic"
"Snd" => "audio/basic"
"Mid" => "audio/midi"
"Midi" => "audio/midi"
"Kar" => "audio/midi"
"Mpga" => "audio/mpeg"
"Mp2" => "audio/mpeg"
"Mp3" => "audio/mpeg"
"Aif" => "audio/x-aiff"
"Aiff" => "audio/x-aiff"
"Aifc" => "audio/x-aiff"
"M3u" => "audio/x-mpegurl"
"Ram" => "audio/x-pn-realaudio"
"Rm" => "audio/x-pn-realaudio"
"Rpm" => "audio/x-pn-realaudio-plugin"
"Ra" => "audio/x-realaudio"
"Wav" => "audio/x-wav"
"Pdb" => "chemical/x-pdb"
"Xyz" => "chemical/x-xyz
"Bmp" => "image/bmp"
"Gif" => "image/gif"
"Ief" => "image/ief"
"Jpeg" => "image/jpeg"
"Jpg" => "image/jpeg"
"Jpe" => "image/jpeg"
"Png" => "image/png"
"Tiff" => "image/tiff"
"Tif" => "image/tiff"
"Djvu" => "image/vnd. djvu"
"Djv" => "image/vnd. djvu"
"Wbmp" => "image/vnd. wap. wbmp"
"Ras" => "image/x-cmu-raster"
"Pnm" => "image/x-portable-anymap"
"Pbm" => "image/x-portable-bitmap"
"Pgm" => "image/x-portable-graymap"
"Ppm" => "image/x-portable-pixmap"
"Rgb" => "image/x-rgb"
"Xbm" => "image/x-xbitmap"
"Xpm" => "image/x-xpixmap"
"Xwd" => "image/x-xwindowdump"
"Ig" => "model/iges"
"Iges" => "model/iges"
"Msh" => "model/mesh"
"Mesh" => "model/mesh"
"Silo" => "model/mesh"
"Wrl" => "model/fig"
"Fig" => "model/fig"
"Css" => "text/css"
"Html" => "text/html"
"Htm" => "text/html"
"Asc" => "text/plain"
"Txt" => "text/plain"
"Rtx" => "text/richtext"
"Rtf" => "text/rtf"
"Sgml" => "text/sgml"
"Sgm" => "text/sgml"
"Tsv" => "text/tab-separated-values"
"Wml" => "text/vnd. wap. wml"
"Wmls" => "text/vnd. wap. wmlscript"
"Etx" => "text/x-setext"
"Xsl" => "text/xml"
"Xml" => "text/xml"
"Mpeg" => "video/mpeg"
"Mpg" => "video/mpeg"
"Mpe" => "video/mpeg"
"Qt" => "video/quicktime"
"Mov" => "video/quicktime"
"Mxu" => "video/vnd. mpegurl"
"Avi" => "video/x-msvideo"
"Movie" => "video/x-sgi-movie"
"Ice" => "x-conference/x-cooltalk"