Exemplo n.º 1
0
        /// <summary>
        /// Returns html content type.
        /// </summary>
        public static string ContentType(string fileName)
        {
            // ContentType
            string fileNameExtension = UtilFramework.FileNameExtension(fileName);
            string result; // https://www.sitepoint.com/web-foundations/mime-types-complete-list/

            switch (fileNameExtension)
            {
            case ".html": result = "text/html"; break;

            case ".css": result = "text/css"; break;

            case ".js": result = "text/javascript"; break;

            case ".map": result = "text/plain"; break;

            case ".png": result = "image/png"; break;

            case ".ico": result = "image/x-icon"; break;

            case ".jpg": result = "image/jpeg"; break;

            case ".pdf": result = "application/pdf"; break;

            case ".json": result = "application/json"; break;

            case ".xlsx": result = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break;

            default:
                result = "text/plain"; break;     // Type not found!
            }
            return(result);
        }