Hello to all,

I've written this thread because I want to know the different content types used like.................

Response.AddHeader("Content-Type", "Application/octet-stream");

It was used for software and It was successful........But what for Music,Pictures and E-Books ???????????

Thanks in advance...........

Dani AI

Generated

Quick answer for : an HTTP response has a single Content-Type that describes the whole body. You can’t meaningfully attach several different MIME types to one ordinary response and expect the browser to treat each part as a separate file. What you did to force a download (using a generic binary MIME) is fine for one file; for music, images or e-books use the specific MIME that matches the file (for example MP3 -> audio/mpeg, JPG -> image/jpeg, EPUB -> application/epub+zip or PDF -> application/pdf).

To serve one file correctly from ASP.NET, map the filename to a MIME type and set the response headers (example shows the pattern; adjust for your .NET version):

string mime = MimeMapping.GetMimeMapping(filePath);   // .NET 4.5+
Response.ContentType = mime;
Response.AppendHeader("Content-Disposition", "attachment; filename=\"" + Path.GetFileName(filePath) + "\"");
Response.TransmitFile(filePath);
HttpContext.Current.ApplicationInstance.CompleteRequest();

If you need to deliver multiple files in a single download, bundle them (ZIP) and send application/zip. Building a zip in-memory and transmitting it is the most compatible approach; browsers will not split a multipart/mixed response into separate downloadable files in general, so multipart MIME is only useful when the client explicitly understands it (or for specific streaming use-cases like MJPEG).

References and further reading: MDN’s MIME overview (MDN: MIME types), the IANA media-types registry (IANA media types), ASP.NET MimeMapping docs (MimeMapping.GetMimeMapping) and multipart rules in RFC 2046 (RFC 2046). Also note ASP.NET Core uses different APIs (FileResult/PhysicalFile) if you’re on that stack.

Recommended Answers

All 3 Replies

Actually I'm askin how to add multiple content types in a single Response.Headers() ???????

i dnt think thats gonna happen...
get it confirm with AdaPost

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.