I would not want to use MemoryStreamfor video. Assuming that you can create CryptoStream(found in the namespace System.Security.Cryptography), the encrypted file AVI, you just have to pump Readfrom it up Writeon Response.OutputStreamto IHttpHandlersomething like: -
byte[] buffer = new byte[65556];
CryptoStream inStream = YourFunctionToDecryptAVI(aviFilePath);
int bytesRead = inStream.Read(buffer, 0, 65556);
while (bytesRead != 0)
{
context.Response.OutputStream.Write(buffer, 0, bytesRead);
bytesRead = inStream.Read(buffer, 0, 65556);
if (!context.Response.IsClientConnected) break;
}
Response.Close();
Make sure you turn off the response buffer and specify the type of content.
Edit
Usually I hate to call closely, it seems draconian. However, while coded encoding should not require this, in the case of streaming video it may be that the client does not like it. Also with large data transfers, closing the connection does not really matter much.
source
share