GetMIMEType() public static method

public static GetMIMEType ( string extension ) : string
extension string
return string
        private bool ServeEmbeddedResource(HTTPResponse response, Assembly assembly,
                                           string strippedResourceName)
        {
            string fullResourceName = FullResourceName(assembly, strippedResourceName);

            if (!string.IsNullOrEmpty(fullResourceName))
            {
                try
                {
                    using (Stream resourceStream = assembly.GetManifestResourceStream(fullResourceName))
                        if (resourceStream != null)
                        {
                            string extension = Path.GetExtension(strippedResourceName);
                            response.SetHeader(HTTPHeader.ContentType, MIMETypeMap.GetMIMEType(extension));
                            response.SetHeader(HTTPHeader.LastModified, File.GetLastWriteTime(assembly.Location).ToHTTPDate());
                            response.WriteStream(resourceStream);
                            return(true);
                        }
                }
                catch
                {
                }
            }
            return(false);
        }
Exemplo n.º 2
0
        private void ServeFile(string filePath, HTTPResponse response)
        {
            string extension = Path.GetExtension(filePath);

            response.SetHeader(HTTPHeader.ContentType, MIMETypeMap.GetMIMEType(extension));
            response.SetHeader(HTTPHeader.LastModified, System.IO.File.GetLastWriteTime(filePath).ToHTTPDate());

            using (var stream = File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.Read))
                response.WriteStream(stream);
        }
Exemplo n.º 3
0
        private void ServeFile(string filePath, HTTPResponse response)
        {
            string extension = Path.GetExtension(filePath);

            response.SetHeader(HTTPHeader.ContentType, MIMETypeMap.GetMIMEType(extension));
            response.SetHeader(HTTPHeader.LastModified, System.IO.File.GetLastWriteTime(filePath).ToHTTPDate());
            FileStream file = File.Open(filePath, FileMode.Open);

            response.WriteStream(file);
            file.Close();
        }