elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado:


+  Foro de elhacker.net
|-+  Programación
| |-+  Desarrollo Web (Moderador: #!drvy)
| | |-+  Por qué no me funciona este codigo?
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Por qué no me funciona este codigo?  (Leído 2,264 veces)
luison

Desconectado Desconectado

Mensajes: 95


Ver Perfil
Por qué no me funciona este codigo?
« en: 24 Septiembre 2010, 21:57 pm »

Código
  1. Sub DownloadFile(ByVal virtualPath As String)
  2.        ' retrieve the physical path of the file to download, and create
  3.        ' a FileInfo object to read its properties
  4.        Dim FilePath As String = Server.MapPath(virtualPath)
  5.        Dim TargetFile As New System.IO.FileInfo(FilePath)
  6.  
  7.        ' clear the current output content from the buffer
  8.        Response.Clear()
  9.        ' add the header that specifies the default filename for the Download/
  10.        ' SaveAs dialog
  11.        Response.AddHeader("Content-Disposition", "attachment; filename=" + _
  12.         TargetFile.Name)
  13.        ' add the header that specifies the file size, so that the browser
  14.        ' can show the download progress
  15.        Response.AddHeader("Content-Length", TargetFile.Length.ToString())
  16.        ' specify that the response is a stream that cannot be read by the
  17.        ' client and must be downloaded
  18.        Response.ContentType = "application/octet-stream"
  19.        ' send the file stream to the client
  20.        Response.WriteFile(TargetFile.FullName)
  21.        ' stop the execution of this page
  22.        Response.End()
  23.    End Sub
  24.  
  25. +---------------------------------------------------------------+
  26. Lo que quiero lograr es que usuarios de mi sitio asp.net, puedan descargar archivos, pero hasta ahorita, ese codigo
  27. funciona del lado del servidor, cuando publico el sitio y lo intento, se descarga el archivo pero con contenido
  28. del front de la pagina donde hago click para descargar, o bien con caracteres raros.
  29.  
  30. Alguien sabe a que se debe que no me funcione del lado del cliente?
  31.  
  32. Gracias por sus comentarios.
  33.  


En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
Porque no me funciona este codigo
Programación C/C++
0xDani 3 3,292 Último mensaje 11 Junio 2012, 00:40 am
por 0xDani
Me explican si este código funciona [Bat]
Scripting
WIитX 2 3,422 Último mensaje 27 Agosto 2012, 07:03 am
por Eleкtro
codigo 10 este dispositivo no puede iniciar--- teclado no funciona
Windows
sub-slfredo 1 4,757 Último mensaje 7 Julio 2013, 06:54 am
por Damiskp
No funciona este simple codigo
Programación Visual Basic
luis456 6 5,001 Último mensaje 21 Septiembre 2013, 08:50 am
por luis456
[AYUDA] No funciona este código
ASM
tete55 7 4,344 Último mensaje 10 Diciembre 2014, 22:36 pm
por Vaagish
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines