We are blocking some file extension and here is our problem:
The error page Media Type Blocked is appearing AFTER downloading the entire file.
So if the user download a forbidden exe of 700 MB, the file is completely downloaded before the Web Gateway block it.
the Property MediaType.EnsuredType means that MWG has to ensure the MediaType, which means the complete file will be downloaded to make sure we get the correct MediaType. You can try MediaType.FromHeader, which should prevent the file from being downloaded completely. In this case however we trust the MediaType the Webserver sends us, and do not analyze the complete file to detect its Media Type.