public void EstimateResponseInfo() { IEncoder guessedEncoder = null; //Only use an encoder to determine extension/mime-type when it's an image extension or when we've set process = always. if (ProcessingIndicated) { guessedEncoder = conf.GetImageBuilder().EncoderProvider.GetEncoder(new ResizeSettings(this.RewrittenInstructions), this.RewrittenVirtualPath); if (guessedEncoder == null) { throw new ImageProcessingException("Image Resizer: No image encoder was found for the request."); } } //Determine the file extension for the caching system to use if we aren't processing the image //Use the existing one if is an image extension. If not, use "unknown". // We don't want to suggest writing .exe or .aspx files to the cache! string fallbackExtension = PathUtils.GetFullExtension(RewrittenVirtualPath).TrimStart('.'); if (!conf.IsAcceptedImageType(RewrittenVirtualPath)) { fallbackExtension = "unknown"; } //Determine the mime-type if we aren't processing the image. string fallbackContentType = "application/octet-stream"; //Support JPEG, PNG, GIF, BMP, TIFF mime-types. Otherwise use "application/octet-stream". //We can't set it to null - it will default to text/html System.Drawing.Imaging.ImageFormat recognizedExtension = DefaultEncoder.GetImageFormatFromExtension(fallbackExtension); if (recognizedExtension != null) { fallbackContentType = DefaultEncoder.GetContentTypeFromImageFormat(recognizedExtension); } EstimatedContentType = ProcessingIndicated ? guessedEncoder.MimeType : fallbackContentType; EstimatedFileExtension = ProcessingIndicated ? guessedEncoder.Extension : fallbackExtension; Performance.GlobalPerf.Singleton.IncrementCounter("module_response_ext_" + EstimatedFileExtension); }