Bloom.Api.ServerBase.GetContentType C# (CSharp) Метод

GetContentType() публичный статический Метод

public static GetContentType ( string extension ) : string
extension string
Результат string
        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";
            }
        }

Usage Example

Пример #1
0
        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);
        }