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 64965
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T18:52:21+00:00 2026-05-10T18:52:21+00:00

I am using ASP.NET to transmit a .jar file. This code works perfectly on

  • 0

I am using ASP.NET to transmit a .jar file. This code works perfectly on IE. However on Firefox the file downloads, corrupt. What is the best way to fix it? Below is the code I am using.

private void TransferFile() {     try     {         string filePath = Server.MapPath('SomeJarFIle.jar');          FileInfo file = new FileInfo(filePath);          if (file.Exists)         {             // Clear the content of the response             //Response.ClearContent();             Response.Clear();              // LINE1: Add the file name and attachment, which will force the open/cance/save dialog to show, to the header             Response.AddHeader('Content-Disposition', 'attachment; filename=' + file.Name);              // Add the file size into the response header             Response.AddHeader('Content-Length', file.Length.ToString());              // Set the ContentType             Response.ContentType = ReturnExtension(file.Extension.ToLower());              // Write the file into the response             //Response.TransmitFile(file.FullName);             Response.WriteFile(file.FullName);              // End the response             Response.End();         }         else         {             this.Response.Write('Error in finding file.  Please try again.');             this.Response.Flush();         }     }     catch (Exception ex)     {         this.Response.Write(string.Format('Error: {0}', ex.Message));     } }    private string ReturnExtension(string fileExtension) {     switch (fileExtension)     {         case '.htm':         case '.html':         case '.log':             return 'text/HTML';         case '.txt':             return 'text/plain';         case '.doc':             return 'application/ms-word';         case '.tiff':         case '.tif':             return 'image/tiff';         case '.asf':             return 'video/x-ms-asf';         case '.avi':             return 'video/avi';         case '.zip':             return 'application/zip';         case '.xls':         case '.csv':             return 'application/vnd.ms-excel';         case '.gif':             return 'image/gif';         case '.jpg':         case 'jpeg':             return 'image/jpeg';         case '.bmp':             return 'image/bmp';         case '.wav':             return 'audio/wav';         case '.mp3':             return 'audio/mpeg3';         case '.mpg':         case 'mpeg':             return 'video/mpeg';         case '.rtf':             return 'application/rtf';         case '.asp':             return 'text/asp';         case '.pdf':             return 'application/pdf';         case '.fdf':             return 'application/vnd.fdf';         case '.ppt':             return 'application/mspowerpoint';         case '.dwg':             return 'image/vnd.dwg';         case '.msg':             return 'application/msoutlook';         case '.xml':         case '.sdxl':             return 'application/xml';         case '.xdp':             return 'application/vnd.adobe.xdp+xml';         case '.jar':             return 'application/java-archive';         default:             return 'application/octet-stream';     } }  

UPDATE:

I added the type

case '.jar':     return 'application/java-archive'; 

And that did not fix the problem. If I zipped up the .jar file it was able to be transmitted fine.

I did notice when I tested againist my localhost the file was downloaded with no issues. However when I push it up to the web server is when I get the problem.

  • 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. 2026-05-10T18:52:21+00:00Added an answer on May 10, 2026 at 6:52 pm

    I don’t see a case for ‘.jar’ in the ReturnExtension() function (which I think might be better off named ‘ReturnMimetype’). Could that be the problem, or did you just forget to paste it in?

    The mimetype for .jar is supposed to be application/java-archive. Details here: http://en.wikipedia.org/wiki/Jar-file

    I think this is the issue. I remember having the same type of problem when I transmitted a .docx file (which is actually a zip file with a different extension, as a .jar files). The download worked fine in IE, but Firefox corrupted it. The solution was to send the correct mimetype.

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

Sidebar

Ask A Question

Stats

  • Questions 58k
  • Answers 58k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer You're calling mysql_query() twice, once with a non-existent $sql parameter:… May 11, 2026 at 8:50 am
  • added an answer I would tend to cache this in your service layer.… May 11, 2026 at 8:50 am
  • added an answer How about something like this? <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML… May 11, 2026 at 8:50 am

Top Members

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Explore

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

Footer

Related Questions

No related questions found

© 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.