Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7723581
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T04:28:40+00:00 2026-06-01T04:28:40+00:00

I am developing a web application with which user can view files in the

  • 0

I am developing a web application with which user can view files in the iPad (Safari browser). I am able to download and view .pdf, .doc,.ppt files. But i am unable to download and view MP4 and 3GP files. I have added correct mime type in the IIS. I am getting following error in Safari (iPad) “BYTE_RANGE_ERROR_MESSAGE”. I am using IIS 7.0 in Windows Server 2008.

Note:I am able to download all the files in PC using IE, Mozilla and Safari.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T04:28:41+00:00Added an answer on June 1, 2026 at 4:28 am

    Sample code below will help you to stream mp4 video via asp.net handler.

    private void RangeDownload(string fullpath,HttpContext context)
    {
         long size,start,end,length,fp=0;
         using (StreamReader reader = new StreamReader(fullpath))
         {             
            size = reader.BaseStream.Length;       
            start = 0;
            end = size - 1;
            length = size;
           context.Response.AddHeader("Accept-Ranges", "0-" + size);
    
          if (!String.IsNullOrEmpty(context.Request.ServerVariables["HTTP_RANGE"]))
          {
              long anotherStart = start;
                   long anotherEnd = end;
                   string[] arr_split = context.Request.ServerVariables["HTTP_RANGE"].Split(new char[] { Convert.ToChar("=") });
                  string range = arr_split[1];
    
                 // Make sure the client hasn't sent us a multibyte range
                 if (range.IndexOf(",") > -1)
                {                    
                       context.Response.AddHeader("Content-Range", "bytes " + start + "-" + end + "/" + size);
                       throw new HttpException(416, "Requested Range Not Satisfiable");
    
                  }
    
    
                  if (range.StartsWith("-"))
                   {
                       // The n-number of the last bytes is requested
                       anotherStart = size - Convert.ToInt64(range.Substring(1));
                  }
                  else
                  {
                      arr_split = range.Split(new char[] { Convert.ToChar("-") });
                      anotherStart = Convert.ToInt64(arr_split[0]);
                    long temp = 0;
                       anotherEnd = (arr_split.Length > 1 && Int64.TryParse(arr_split[1].ToString(), out temp)) ? Convert.ToInt64(arr_split[1]) : size;
                   }
    
                  anotherEnd = (anotherEnd > end) ? end : anotherEnd;
    
                  if (anotherStart > anotherEnd || anotherStart > size - 1 || anotherEnd >= size)
                  {
    
                      context.Response.AddHeader("Content-Range", "bytes " + start + "-" + end + "/" + size);
                    throw new HttpException(416, "Requested Range Not Satisfiable");
                 }
                 start = anotherStart;
                  end = anotherEnd;
    
                  length = end - start + 1; // Calculate new content length
                fp = reader.BaseStream.Seek(start, SeekOrigin.Begin);
                 context.Response.StatusCode = 206;
              }
         }
              // Notify the client the byte range we'll be outputting
          context.Response.AddHeader("Content-Range", "bytes " + start + "-" + end + "/" + size);
          context.Response.AddHeader("Content-Length", length.ToString());
             // Start buffered download
              context.Response.WriteFile(fullpath, fp, length);
              context.Response.End();
    
    }
    

    Sample use of function under ProcessRequest method

    string mimetype = "video/mp4";
    if (System.IO.File.Exists(file))
    {
       context.Response.ContentType = mimetype;
       if (!String.IsNullOrEmpty(context.Request.ServerVariables["HTTP_RANGE"]))
       {
           //request for chunk
           RangeDownload(file, context);
       }
       else    
       {
           //ask for all 
           long fileLength = File.OpenRead(file).Length;
           context.Response.AddHeader("Content-Length", fileLength.ToString());
           context.Response.WriteFile(file);
       }
    }
    else
    {
        throw new HttpException(404, "Video Not Found Path:" + file);
    }
    

    Hope this code will help you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing an web application which can upload/download a file from client to
We are developing a mobile web application which user's can reach via their mobile
I am developing web application in ASP.NET and C#, in which a user should
I am developing a web application which has Chart Controls. I have developed a
We are developing a web application which is available in 3 languages. There are
When developing a new web based application which version of html should you aim
I'm currently involved with developing a C# CMS-like web application which will be used
I'm developing a web application for a company which I work for. My team
I am developing a C# web application in VS 2008 which interacts with my
I am developing a Cocoa application which communicates constantly with a web service to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.