1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Extract ID From URL To Include In Installer / Desktop Application?

Discussion in 'General Programming Chat' started by MatthewWoodward, Nov 12, 2012.

  1. MatthewWoodward

    MatthewWoodward Jr. VIP Jr. VIP Premium Member

    Joined:
    Aug 31, 2012
    Messages:
    992
    Likes Received:
    1,681
    Occupation:
    SEO
    Location:
    UK
    Home Page:
    Hi Guys,

    I'm facing a problem that I just can't seem to find a workable solution for.

    I have a windows application written in .net4 that can be downloaded from a URL like this www.website.com/download

    BUT what I want to happen is if someone visits www.website.com/download?ID=12345 the ID somehow gets carried into the setup file/installer so it knows which ID is responsible for the download

    My Current Solution

    What I have thought about so far and I dont even know if its possible is-

    1) Someone loads www.website.com/download?ID=12345
    2) Instead of serving setup.exe to download, the site dynamically serves up setup-12345.exe (renaming the file before sending to the browser)
    3) When the software is installed, it extracts the 12345 bit from the setup file name

    Is that possible?

    Is there a better approach to doing it? I know its possible but how!?

    Thanks
     
  2. jazzc

    jazzc Moderator Staff Member Moderator Jr. VIP

    Joined:
    Jan 27, 2009
    Messages:
    2,468
    Likes Received:
    10,148
    Use this http header on the download script and you 'll be fine

    Code:
    Content-Disposition: attachment; filename=uberfile.exe
    
     
  3. MatthewWoodward

    MatthewWoodward Jr. VIP Jr. VIP Premium Member

    Joined:
    Aug 31, 2012
    Messages:
    992
    Likes Received:
    1,681
    Occupation:
    SEO
    Location:
    UK
    Home Page:
    Hi,

    Could you explain that a little further please? How does that get passed into the program?

    I don't have a download script at the moment

    Thanks
     
  4. jazzc

    jazzc Moderator Staff Member Moderator Jr. VIP

    Joined:
    Jan 27, 2009
    Messages:
    2,468
    Likes Received:
    10,148
    I assumed you had control over the website the setup file exists. If you do, you modify the download script to add that header.

    What that header does is tell the browser what name the downloaded file should have (depending how the .net program has been implemented, this may be automated or you may need to add code to recognize it).

    This way, you can pass the id by "renaming" the file with the steps you proposed.

    Another way to do it, is have the .net program to just parse the id from the url itself and save yourself the trouble :)
     
  5. MatthewWoodward

    MatthewWoodward Jr. VIP Jr. VIP Premium Member

    Joined:
    Aug 31, 2012
    Messages:
    992
    Likes Received:
    1,681
    Occupation:
    SEO
    Location:
    UK
    Home Page:
    Hi,

    I do have full control over it but at the moment the setup is just your usual 'click here to download' a href link direct to the .exe

    However I understand I need a separate script to handle that and do the renaming in the header. I assume within the PHP script you define the location of the original file?

    The proposed way of then getting the ID out of the name of the installer and into the actual application is the setup will write its current path to the registry including the filename and the program will parse that number after setup. Not sure if thats the best approach to handle that bit but it works in theory.

    Thanks for your additional advice!
     
  6. jazzc

    jazzc Moderator Staff Member Moderator Jr. VIP

    Joined:
    Jan 27, 2009
    Messages:
    2,468
    Likes Received:
    10,148
  7. MatthewWoodward

    MatthewWoodward Jr. VIP Jr. VIP Premium Member

    Joined:
    Aug 31, 2012
    Messages:
    992
    Likes Received:
    1,681
    Occupation:
    SEO
    Location:
    UK
    Home Page: