Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
S

smsayami

@smsayami
About
Posts
1
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Problem in opening the content in HttpWebResponse
    S smsayami

    I have a HttpWebResponse object with the content like text, doc, xls, jpg or other files. and I need to display the content open or save way. For that I wrote the code like this: public void DisplayDocument(HttpWebResponse docResponse, string name) { StreamReader reader = new StreamReader(docResponse.GetResponseStream()); string tmpContent = reader.ReadToEnd(); System.Web.HttpContext.Current.Response.ContentType = docResponse.ContentType; System.Web.HttpContext.Current.Response.ClearContent(); System.Web.HttpContext.Current.Response.ContentType = docResponse.ContentType; System.Web.HttpContext.Current.Response.AddHeader("Content-Length", docResponse.ContentLength.ToString()); System.Web.HttpContext.Current.Response.AppendHeader("content-disposition", "attachment;filename=" + Name); System.Web.HttpContext.Current.Response.Write(tmpContent); docResponse.Close(); HttpContext.Current.ApplicationInstance.CompleteRequest(); } If the HttpResponse has text file content, I can open or save. But if it has some other files like image, doc, excel content, they either don't open or opens with garbage content. What's wrong in this code ?

    ASP.NET help question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups