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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. Force Save option to download a file in IE

Force Save option to download a file in IE

Scheduled Pinned Locked Moved ASP.NET
sysadminhelpquestionannouncement
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    SABhatti
    wrote on last edited by
    #1

    I want to force the user to download an excel file instead of opening it in browser. I am using the following code: Response.Clear() Response.ContentType = "application/vnd.ms-Excel" Response.AddHeader("content-disposition", "attachement; filename=" & strFileName) Response.WriteFile(strPath & strFileName) Response.End() the above code gives me the option to save or open at my laptop which is not on the network of my work place but at my work place it always open the file in the browser. I have tested it at three four computer but same result. it does not give hte option to open or save. Browser version is same at my work place and my laptop. Can someone help me please, is it possible to bypass the open save option and force the user to save the file on the local machine using any other coding technique either on client side or server side? -----

    D 1 Reply Last reply
    0
    • S SABhatti

      I want to force the user to download an excel file instead of opening it in browser. I am using the following code: Response.Clear() Response.ContentType = "application/vnd.ms-Excel" Response.AddHeader("content-disposition", "attachement; filename=" & strFileName) Response.WriteFile(strPath & strFileName) Response.End() the above code gives me the option to save or open at my laptop which is not on the network of my work place but at my work place it always open the file in the browser. I have tested it at three four computer but same result. it does not give hte option to open or save. Browser version is same at my work place and my laptop. Can someone help me please, is it possible to bypass the open save option and force the user to save the file on the local machine using any other coding technique either on client side or server side? -----

      D Offline
      D Offline
      dwatkins dirq net
      wrote on last edited by
      #2

      I would assume that the opening behavior is a browser setting. Try looking at the file association settings on your work computer. There is no way to force a client machine to save the file because of security concerns. You can only do what you are doing and let the user decide what to do with your file. You can have some text on the previous page describing what they should do. Dirk Watkins

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

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