Piccolo tutorial su come permettere il download di un file salvato nel server.
creare una web form chiamata "download.aspx" ed incollare questo codice:
codice:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim filepath As String = Request.Params("file")
If Not filepath Is Nothing Then
If File.Exists(filepath) Then
Dim filename As String = Path.GetFileName(filepath)
Response.Clear()
Response.ContentType = "application/octet-stream"
Response.AddHeader("Content-Disposition", _
"attachment; filename=""" & filename & """")
Response.Flush()
Response.WriteFile(filepath)
End If
End If
End Sub
Dalle vostre web form richiamate questa pagina in questo modo:
codice:
<a href="download.aspx?file=c:\percorso\file.estenzione">
oppure
codice:
Response.Redirect("download.aspx?file=c:\percorso\file.estenzione")
L'ho testato con il service pack 2 di Win XP e funziona.
Se trovate bug ditelo.
Fonte
Ciao ciao!