0

I'm trying to send a zip file to navigator in ASP NET Visual Basic, I do the following:

Response.Clear()
Response.AppendHeader("Content-Disposition", "attachment; filename=" + fileName)
Response.ContentType = "application/zip"
Response.WriteFile(fullPath)
Response.End()

I get this strange characters

enter image description here

How can I send the zip to navigator?

Chariot
  • 55
  • 1
  • 13

1 Answers1

1

A zip file is NOT a text file. Don't treat it like a text file. Don't try viewing it like a text file.

Rather, a ZIP file is a binary file format. It is a container (also often called an archive) that contains compressed files. What you see there in your screenshot is just the binary data of the ZIP file. Binary data which whatever viewer you used tried to interpret as character codes -- which of course will not yield any sensible result, because a ZIP file is not a text file. It's not.

If you want to get your hands on the files compressed within the ZIP file, you need to uncompress ("unpack") the ZIP file.

By the way, i can see that the compressed file within the ZIP file is presumably a PDF file. Which is also not a text file, but requires a PDF reader/viewer to display/render it (after it has been unpacked from the ZIP file, obviously...).

  • I'm not treating the zip like a text file because I'm setting this line: application/zip – Chariot May 23 '22 at 14:12
  • Whatever that "navigator" is (which i don't know anything about), it doesn't seem to handle ZIP files as you expect/assume. Since i don't know this "navigator", i can't really give any concrete help or advice about it, aside from the general suggestion of starting with determining and verifying whether and how this "navigator" can deal with ZIP archives, like, "_Does navigator understand the application/zip mime type?_", or "_Do i need to configure navigator in some way to enable ZIP file support?_", and so on... – ZippingAlong May 23 '22 at 14:15
  • I have seen many examples like this https://stackoverflow.com/questions/834527/how-do-i-generate-and-send-a-zip-file-to-a-user-in-c-sharp-asp-net, it works for people... – Chariot May 23 '22 at 14:18
  • Yes, it works for people. It doesn't work for you, though. So you have to figure out what's going on there with that "navigator" of yours. Good luck! – ZippingAlong May 23 '22 at 14:21
  • "Navigator" is Chrome... – Chariot May 23 '22 at 14:22
  • Okay. Why would you expect Chrome to automatically unpack ZIP archives? That's not how Chrome naturally behaves. This begs the question: What do you actually want to happen with the ZIP file, and **why** is it a problem for you that Chrome does not unpack the ZIP archive? – ZippingAlong May 23 '22 at 14:26
  • I just need to "download" the zip into the navigator, not unzip it – Chariot May 23 '22 at 14:27
  • You already downloaded it successfully, as far as i can tell. As i said in my answer: Do not treat a ZIP file as a text file. It is not. That applies to attempting to view the ZIP file as well. So, don't try viewing a ZIP file like a text file, because then you will only see gibberish like in your screenshot. Because, if you attempt to view a binary file like a text file, all you will ever get is some form of gibberish like in your screenshot... – ZippingAlong May 23 '22 at 14:28
  • Ok, so, if I can't treat a ZIP file as a text file, how I treat it to get that I attempt? – Chariot May 23 '22 at 14:34
  • Depends on the computer/device you are using. Most modern desktop operating systems have built-in support for ZIP archives -- a double-click on the ZIP file should either unpack it or open it like a directory. If this doesn't work then you need an unpacker for ZIP files. There are different kinds of 3rd-party software for this task for various operating systems and devices. And quite likely there are also Chrome extensions that can do this (although i don't know any concrete candidate from the top of my head) – ZippingAlong May 23 '22 at 14:37
  • 1
    And what you then do with the unpacked file(s) depends on the nature of these files themselves. Like in your case, the ZIP file containing a PDF file (as it seems). PDF is also not a human-readable text file in any meaningful sense. (It is a file format describing pages page content and layout, with the content possibly being text -- but that does not make the PDF file data itself human-readable.) So, to view a PDF file, your operating system/device needs a capability for displaying PDF files. If it doesn't have built-in support for PDF files, you will need to install some PDF viewer software. – ZippingAlong May 23 '22 at 14:42