Page 3 of 3 FirstFirst 123
Results 21 to 23 of 23

Thread: Chrome V2 download issues

  1. #21
    Forum User verified
    Join Date
    Oct 2010
    Owner Since
    1993

    Location
    St Louis
    Posts
    343
    Thanks
    29
    Thanked 48 Times in 31 Posts
    I had tried various implementations of the response function but ultimately found redirect to work... Mainly there is code that has to fire AFTER the file is served... namely db updates. Also the method I use now obfuscates the actual file name.

    However, I will try response.transmitfilename as I don't think I tried that...

    No need to recreate the error. Google chrome has built in "helpers" and viewers which don't really help... Lol
    www.ClonedECU.com
    The home of the Original Clone and Clone2 ECU!
    More Plug n' Drive and less Plug n' Fail like the others!
    Remember, if it's not a Clone, it's just a copy!

    Get Chromed!
    Donate Now and receive a coupon code for the amount of your donation (up to $50.00 US) which you can apply at check out for a Clone2 ECU, Plug n’ Play Harness, or Clone2 Plug n’ Play Package!!
    1999 3000GT VR4
    Glacier Pearl White
    Yeah it's stock . . . trust me
    How To Contact Me:
    eMail: brett_farnam@yahoo.com
    US3S/3SGTO: 99 vr4
    3SI: bfarnam

  2. #22
    Forum User Not Verified

    Join Date
    Sep 2010
    Owner Since
    2004

    Location
    Cape Girardeau
    Posts
    4,791
    Thanks
    365
    Thanked 296 Times in 214 Posts
    you can set the file name in the headers to anything you want. There is some code missing above that creates the file object using the actual path to the file on the server.

    I also pull the file out of a folder outside of the web root, even if they had the real filename it would not be possible to download it.

    Parting 6 speed
    Pampena 3.5 Stroker, GTX 2867 Gen IIs, AEM Series2, oohnoo SMIC, DN Hardpipes, FIC 1650s, Walbro 525, aermotive fpr, Dejon intake pipes, Tial Q, Koyo Rad, Samco Hoses, Stoptech 332mm fronts, HKS GT4 Coilovers, Spec 4+ LW, JDM 6 Speed, Billet shift forks, Pampena brace

  3. #23
    Forum User verified
    Join Date
    Oct 2010
    Owner Since
    1993

    Location
    St Louis
    Posts
    343
    Thanks
    29
    Thanked 48 Times in 31 Posts
    Chris . . . I looked at some of my old code when I was trying to get this to work . . .

    Code:
    Sub btnDownload_Click(Sender As Object, E As EventArgs)
    	if page.IsValid
    		Response.ContentType = "application/zip"
    		Response.AppendHeader("Content-Disposition","attachment; filename=MySaveAsFile.zip")
    		Response.TransmitFile( server.mappath("MyPath/MyFile.zip") )
    		Response.End
    	end if
    End Sub
    This did not work as we would expect. Although the file transmitted flawlessly, response.end terminates any further code execution. and there is more code in the current sub to update the databases that the file was indeed downloaded. I even tried:

    Code:
    Server.Execute("MyPath/MyFile.zip")
    What I have now is as follows:

    Code:
    Sub btnDownload_Click(Sender As Object, E As EventArgs)
    	if page.IsValid 
    
    		' First get the purchase data (This should have already been done)
    		getPurchaseData()
    
    		' Serve the file - will auto rename to the page name with ".zip"
    		if vPurchasedFile = "Chrome SL v1.0 Donation" then Server.Execute("MyPath/MyFile.zip")
    		if vPurchasedFile = "Chrome v2.0 Donation" then Server.Execute("MyPath/MyFile.zip")
    		
    		' increment the downloads
    		vNumberDownloads = vNumberDownloads + 1
    
    		' update the Purchase database with the total number of downloads	
    '		strSQL = "UPDATE [Purchased] SET [Downloads]='" & vNumberDownloads & "' and [EULA] = "true" WHERE tGUID='" & session("vGUID") & "'"
    		strSQL = "(UPDATE [Purchased] SET [Downloads] = @NumDownloads, [EULA] = @EULADone WHERE [tGUID] = @vGUID)"
    
    		dbCommand = New OleDbCommand(strSQL, objConnection)
    
    		dbCommand.Parameters.AddWithValue("@NumDownloads", vNumberDownloads)
    		dbCommand.Parameters.AddWithValue("@EULADone", "1")
    		dbCommand.Parameters.AddWithValue("@vGUID", session("vGUID"))
    
    		Try
    	      objConnection.Open()
    	      dbCommand.ExecuteNonQuery()
    	    Catch ex As Exception
    	      Response.Write("<h2 class=""b_maroon"">" & ex.Message & "</h2>")
    	      Response.End
    	    Finally
    	      If objConnection.State = ConnectionState.Open Then objConnection.Close()
    	    End Try
    '		Response.Write("<h2 class=""b_orange"">A purchase record has been updated!!</h2>")
    
    		' Create the NEW download completed record and insert into the database
    		strSQL = "INSERT INTO Downloads (tGUID, dDate, dIP) VALUES (@tGUID, @dDate, @dIP)"
    
    		dbCommand = New OleDbCommand(strSQL, objConnection)
    
    		dbCommand.Parameters.AddWithValue("@tGUID", session("vGUID"))
    		dbCommand.Parameters.AddWithValue("@dDate", DateTime.Now.ToString())
    		dbCommand.Parameters.AddWithValue("@pIP", UserIPAddress)
    
    	    Try
    			objConnection.Open()
    	    	dbCommand.ExecuteNonQuery()
    	    Catch ex As Exception
    	    	Response.Write("<h2 class=""b_maroon"">" & ex.Message & "</h2>")
    	    	Response.End
    	    Finally
    	    	If objConnection.State = ConnectionState.Open Then objConnection.Close()
    	    End Try
    '		Response.Write("<h2 class=""b_orange"">A new download record has been added!!</h2>")
    
    	End If
    End Sub
    If you could shed some light on a better way of doing this I would love to hear it. I thought about using a popup but most browsers block the popups. The popup could be passed hidden parms to enable the down load and the db update code could still be run.

    The page logic is as follows:

    Is there a admin query present in the QueryString?
    Then show admin data. Page Quit.

    Else Is this a PayPal return (from purchase/donation)?
    Then show finalize PayPal purchase/donation by
    creating db records
    generate email
    show download button

    Else Is this a return file download?
    Then determine if download allowed (max days, max downloads)
    if agreed to terms then precheck the terms box and show download button
    Else show error

    Else This MUST be a first visit
    show first impression with donation buttons

    There is also present a css and I have not moved this to code behind mainly becuase there is very little code - its mostly building the output which is displayed via response.write. I traditionally was an asp developer and asp.net is new to me over the past year. VB vs. VB.net really had a lot of little syntax changes that caused me great headaches . . . LOL

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
The 3000GT/Stealth/GTO Web History Project
3000gt.com
3000GT / Stealth International WWWboard Archive
Jim's (RED3KGT) Reststop
3000GT/Stealth/GTO Information and Resources
Team 3S
3000GT / Stealth / GTO Information
daveblack.net
3000GT/Stealth/GTO Clubs and Groups
Michigan 3S
MInnesota 3S
Wisconsin 3S
Iowa, Nebraska, Kansas 3S
North California 3000GT/Stealth
United Society of 3S Owners
3000GT/Stealth/GTO Forums
3000GT/Stealth International
3000GT/Stealth/GTO Event Pages
3S National Gathering
East Coast Gathering
Upper Mid-West Gathering
Blue Ridge Gathering