public static string GetContentType(string extension) { switch (extension) { case ".css": return "text/css"; case ".gif": return "image/gif"; case ".htm": case ".html": return "text/html"; case ".jpg": case ".jpeg": return "image/jpeg"; case ".js": return "application/x-javascript"; case ".png": return "image/png"; case ".pdf": return "application/pdf"; case ".txt": return "text/plain"; case ".svg": return "image/svg+xml"; default: return "application/octet-stream"; } }
public void ReplyWithImage(string path, string originalPath = null) { var pos = path.LastIndexOf('.'); if (pos > 0) { _actualContext.Response.ContentType = ServerBase.GetContentType(path.Substring(pos)); } ReplyWithFileContent(path, originalPath); }