
Download file to client machine asp net - question

You can't actually do this. (Security issue.)
But you can create a link that performs a download. It is a bit complicated, because you cannot force a browser to obey you, and it might try to just display the file instead, depending on the settings of the user's machine.
Using 6 and IIS, this is what I do in response to a link click
on <a href="http://MySvr/MyApp.asp?wci=Send_File>Download File</a>
But you can create a link that performs a download. It is a bit complicated, because you cannot force a browser to obey you, and it might try to just display the file instead, depending on the settings of the user's machine.
Using 6 and IIS, this is what I do in response to a link click
on <a href="http://MySvr/MyApp.asp?wci=Send_File>Download File</a>
Private Sub Send_File_Respond() On Error GoTo Er Dim pth As String Dim strDoc As String Dim CntTyp As String Dim fSize As String Dim oStrm As ADODB.Stream strDoc = "StandardMaterials.txt" CntTyp = "text/plain" pth = " . . . " ' Whatever you need here Set oStrm = New ADODB.Stream fSize = GetFileSize(pth & strDoc) Response.Buffer = True ' Turning on buffering & clearing ensures that Response.Clear ' all of the header information will be at the ' top. Feature of IIS 4 and on. oStrm.Open oStrm.Type = adTypeBinary oStrm.LoadFromFile pth & strDoc Response.AddHeader "Content-Disposition", "attachment; filename=" & strDoc Response.AddHeader "Content-Length", fSize Response.ContentType = CntTyp Response.Charset = "UTF-8" Response.BinaryWrite oStrm.Read Response.Flush oStrm.Close Set oStrm = Nothing Rs: Exit Sub Er: ' Report or log the error here, if there is one... Resume Rs End Sub
-