Old Site

This site is archived. I now update and maintain my blog here.

Solution: Help DRM and forward lock

I had a few mails asking if I resolved the forward lock and C# problem that I was having. The working code is below, I am not sure if it is the best way to do this, but it does work.

Stream str = File.Open(Server.MapPath(Request["file"]), FileMode.Open); 
byte [] buffer = new byte[str.Length]; 
str.Read(buffer, 0, Convert.ToInt32(str.Length)); 

Response.Charset = ""; 
Response.AddHeader("Accept-Ranges", "bytes"); 
Response.ContentType = "application/vnd.oma.drm.message"; 
String header = "--mime_content_boundary\r\nContent-Type: image/gif\r\nContent-Transfer-Encoding: binary\r\n\r\n"; 
String footer = "\r\n--mime_content_boundary--"; 

System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding(); 
Response.WriteFile(Server.MapPath(Request["file"])); Response.BinaryWrite(encoding.GetBytes(footer));
Leave a comment