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. Allow only user logged in download ?

Allow only user logged in download ?

Scheduled Pinned Locked Moved ASP.NET
tutorialquestionworkspace
4 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.
  • G Offline
    G Offline
    god4k
    wrote on last edited by
    #1

    Dear Sir and Madam When my user logged in, I set Session["user"] = UserID. How to allow only user who logged in download files. (for example: setup.exe, demo.zip)? Sorry for bad English Thank You.

    A M G 3 Replies Last reply
    0
    • G god4k

      Dear Sir and Madam When my user logged in, I set Session["user"] = UserID. How to allow only user who logged in download files. (for example: setup.exe, demo.zip)? Sorry for bad English Thank You.

      A Offline
      A Offline
      Ashutosh Phoujdar
      wrote on last edited by
      #2

      Sure[^]

      dnpro "Very bad programmer" My Latest Articles RichTextBox Control with Find functionality LogViewer - A Simple Log Listening Utility

      1 Reply Last reply
      0
      • G god4k

        Dear Sir and Madam When my user logged in, I set Session["user"] = UserID. How to allow only user who logged in download files. (for example: setup.exe, demo.zip)? Sorry for bad English Thank You.

        M Offline
        M Offline
        Manas Bhardwaj
        wrote on last edited by
        #3

        You surely need to buy a ASP.Net book. In between, check the value of Session["user"]. If it is not null, allow the download else ask him to get out :rose:

        Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.

        1 Reply Last reply
        0
        • G god4k

          Dear Sir and Madam When my user logged in, I set Session["user"] = UserID. How to allow only user who logged in download files. (for example: setup.exe, demo.zip)? Sorry for bad English Thank You.

          G Offline
          G Offline
          god4k
          wrote on last edited by
          #4

          Response.Clear(); Response.ContentType = "application/octet-stream"; Response.AddHeader("Content-Disposition", "attachment;filename=" + fileName); System.IO.FileStream sourceFile = new System.IO.FileStream(path, System.IO.FileMode.Open); long FileSize = sourceFile.Length; byte[] content = new byte[(int)FileSize]; sourceFile.Read(content, 0, (int)sourceFile.Length); sourceFile.Close(); Response.BinaryWrite(content); Response.End();

          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