code-tutorial.com

The best resources for developers

Displaying ad content from Respone.WriteFile()/Respone.ContentType.Response.ContentType(Response.WriteFile()/Reponse.ContentType().Response.WriteFile()/Reponse.ContentType(Response.ContentType()).Response.WriteFile()

switch ( fileExtension )
{
    case "pdf": Response.ContentType = "application/pdf"; break; 
    case "swf": Response.ContentType = "application/x-shockwave-flash"; break; 

    case "gif": Response.ContentType = "image/gif"; break; 
    case "jpeg": Response.ContentType = "image/jpg"; break; 
    case "jpg": Response.ContentType = "image/jpg"; break; 
    case "png": Response.ContentType = "image/png"; break; 

    case "mp4": Response.ContentType = "video/mp4"; break; 
    case "mpeg": Response.ContentType = "video/mpeg"; break; 
    case "mov": Response.ContentType = "video/quicktime"; break; 
    case "wmv":
    case "avi": Response.ContentType = "video/x-ms-wmv"; break; 

    //and so on          

    default: Response.ContentType = "application/octet-stream"; break; 
}

Tags: c#

Source: By FryHard as answer to the question

This code snippet was collected from stackoverflow, and is licensed under CC BY-SA 2.5


Related code-snippets: