Descargar un fichero


Truco de ASP.NET - Descargar un fichero



Podemos descargar un fichero del servidor Web con este código:



Dim filepath As String = "c:\test.txt"


Dim filename As String = "test"


Response.Clear()


Response.ContentType = "application/octet-stream"


Response.AddHeader("Content-Disposition", "attachment; filename=" + filename)


Response.Flush()


Response.WriteFile(filepath)


Response.End()


Pon el truco en tus favoritos Pon el truco en tus favoritos