.Net HttpHandler not working in android device
<p>I have created ASP.Net httphandler to count number of visits for MP3 files. Httphandler is being used in web application as well as in ios + android application.</p>

<p>It is working fine in web + ios application. If I run android application in Samsung Galaxy S then it is playing MP3 files perfectly but it is not working in Samsung Galaxy Ace mobile. </p>

<p>I do not know what is wrong in my asp.net code. Below is code of httphandler. </p>

<pre><code>public class MP3DownloadHanlder : IHttpHandler , IRequiresSessionState
  {

      public void ProcessRequest(HttpContext context)
      {
              //Here I increment number of visit by filename in request
              string filename = context.Request.QueryString["Title"] + ".mp3";
              string path = context.Server.MapPath("audio");
              string file = path + "\\" + filename;
              if (System.IO.File.Exists(file))
              {
                  FileStream fs = new FileStream(file, FileMode.Open, FileAccess.Read);
                  context.Response.Buffer = true;
                  context.Response.Clear();
                  context.Response.ClearContent();
                  context.Response.ClearHeaders();
                  context.Response.AddHeader("content-disposition", "attachment; filename=" + filename);
                  context.Response.AddHeader("content-length", fs.Length.ToString());
                  context.Response.ContentType = "audio/mpeg";
                  byte[] bytes = new byte[fs.Length];
                  int bytesToRead = (int)fs.Length;
                  int bytesRead = 0;
                  while (bytesToRead &gt; 0)
                  {
                      int n = fs.Read(bytes, bytesRead, bytesToRead);
                      if (n == 0) break;
                      bytesRead += n;
                      bytesToRead -= n;
                  }
                  bytesToRead = bytes.Length;
                  context.Response.OutputStream.Write(bytes, 0, bytes.Length);
              }

          context.Response.End();
      }

      public bool IsReusable
      {
          get
          {
              return false;
          }
      }
  }
</code></pre>

<p>Please help me. It is urgent for me</p>

<p>Regards,
Viral</p>
