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
  1. Home
  2. Web Development
  3. ASP.NET
  4. file downloading prblm

file downloading prblm

Scheduled Pinned Locked Moved ASP.NET
helpsysadminquestion
8 Posts 3 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.
  • V Offline
    V Offline
    Vanamaindia
    wrote on last edited by
    #1

    I'm downloading a file from server using this code Response.Clear() Response.AddHeader("Content-Disposition", "attachment; filename=" & file.Name) Response.AddHeader("Content-Length", file.Length.ToString()) Response.ContentType = "text/plain" Response.WriteFile(file.FullName) Response.End() it's working fine but i've to clear the page cache below the code Response.Expires = 0 Response.Cache.SetNoStore() Response.AppendHeader("Pragma", "no-cache") i'm clearing the cache using above code both r working fine but i'm unable to open the downloaded file through save as dialog box the problem is clearing the cache.. But I've to clear the cache.. how can I do both things .. help me plz

    S N 2 Replies Last reply
    0
    • V Vanamaindia

      I'm downloading a file from server using this code Response.Clear() Response.AddHeader("Content-Disposition", "attachment; filename=" & file.Name) Response.AddHeader("Content-Length", file.Length.ToString()) Response.ContentType = "text/plain" Response.WriteFile(file.FullName) Response.End() it's working fine but i've to clear the page cache below the code Response.Expires = 0 Response.Cache.SetNoStore() Response.AppendHeader("Pragma", "no-cache") i'm clearing the cache using above code both r working fine but i'm unable to open the downloaded file through save as dialog box the problem is clearing the cache.. But I've to clear the cache.. how can I do both things .. help me plz

      S Offline
      S Offline
      soni uma
      wrote on last edited by
      #2

      Add a Response.Flush() After Response.WriteFile(file.FullName)

      V 1 Reply Last reply
      0
      • S soni uma

        Add a Response.Flush() After Response.WriteFile(file.FullName)

        V Offline
        V Offline
        Vanamaindia
        wrote on last edited by
        #3

        it's not working

        S 1 Reply Last reply
        0
        • V Vanamaindia

          it's not working

          S Offline
          S Offline
          soni uma
          wrote on last edited by
          #4

          try using this code it may help you for downloading System.Web.HttpResponse response = System.Web.HttpContext.Current.Response; response.ClearContent(); response.ContentType = "application/octet-stream"; Response.AddHeader("Content-Disposition", "attachment; filename=" ); response.Flush(); response.WriteFile("File"); response.End(); :cool:

          V 1 Reply Last reply
          0
          • V Vanamaindia

            I'm downloading a file from server using this code Response.Clear() Response.AddHeader("Content-Disposition", "attachment; filename=" & file.Name) Response.AddHeader("Content-Length", file.Length.ToString()) Response.ContentType = "text/plain" Response.WriteFile(file.FullName) Response.End() it's working fine but i've to clear the page cache below the code Response.Expires = 0 Response.Cache.SetNoStore() Response.AppendHeader("Pragma", "no-cache") i'm clearing the cache using above code both r working fine but i'm unable to open the downloaded file through save as dialog box the problem is clearing the cache.. But I've to clear the cache.. how can I do both things .. help me plz

            N Offline
            N Offline
            N a v a n e e t h
            wrote on last edited by
            #5

            Vanamaindia wrote:

            how can I do both things ..

            You told, methods used by you are working fine. Then what's the issue here ?

            Vanamaindia wrote:

            but i'm unable to open the downloaded file through save as dialog box

            What do you mean by this ? SaveAs dialog will be shown by the browser. So I don't think that you can control that.

            All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia How to use google | Ask smart questions

            1 Reply Last reply
            0
            • S soni uma

              try using this code it may help you for downloading System.Web.HttpResponse response = System.Web.HttpContext.Current.Response; response.ClearContent(); response.ContentType = "application/octet-stream"; Response.AddHeader("Content-Disposition", "attachment; filename=" ); response.Flush(); response.WriteFile("File"); response.End(); :cool:

              V Offline
              V Offline
              Vanamaindia
              wrote on last edited by
              #6

              It's not working uma

              S 1 Reply Last reply
              0
              • V Vanamaindia

                It's not working uma

                S Offline
                S Offline
                soni uma
                wrote on last edited by
                #7

                Dear, This code working perfectly i had already tried it. You should try google and also try that code in different browser

                V 1 Reply Last reply
                0
                • S soni uma

                  Dear, This code working perfectly i had already tried it. You should try google and also try that code in different browser

                  V Offline
                  V Offline
                  Vanamaindia
                  wrote on last edited by
                  #8

                  System.Web.HttpResponse response = System.Web.HttpContext.Current.Response; response.ClearContent(); response.ContentType = "application/octet-stream"; Response.AddHeader("Content-Disposition", "attachment; filename=" ); response.Flush(); response.WriteFile("File"); response.End(); use this code in page load Response.Expires = 0 Response.Cache.SetNoStore() Response.AppendHeader("Pragma", "no-cache") after that u add ur code in button click.. try this one...

                  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