No se puede abrir el diálogo de guardar descarga
Utilizando el siguiente código, no puedo mostrar el diálogo abrir / guardar como archivo:
public void ProcessRequest(HttpContext context)
{
string link = context.Request.QueryString["Link"];
string extension = Path.GetExtension(link);
string fileName = Path.GetFileName(link);
string fullPath =
String.Format("{0}\\{1}",
context.Server.MapPath("~/Content/Uploads/"),
fileName);
if (File.Exists(fullPath))
{
context.Response.ClearContent();
context.Response.ClearHeaders();
context.Response.AddHeader(
"Content-Length",
new FileInfo(fullPath).Length.ToString());
string contentType;
switch (extension)
{
default:
contentType = "application/octet-stream";
break;
}
context.Response.ContentType = contentType;
context.Response.AddHeader(
"Content-Disposition",
String.Format("attachment; filename={0}", fileName));
context.Response.WriteFile(fullPath, true);
context.Response.Flush();
}
}
He intentado cerrar la respuesta, dejar la respuesta abierta, usarTrasmitFile()
, pero nunca recibo ningún diálogo ni retroalimentación alguna. He intentado depurarlo también, pero no se lanzan excepciones. Probado en IE 7/8, y Chrome. Cualquier ayuda es apreciada.
¡Gracias!
A continuación se muestra la salida de Fiddler:
HTTP / 1.1 200 OK Control de caché: privado Longitud del contenido: 3813 Tipo de contenido: application / octet-stream Servidor: Microsoft-IIS / 7.5 Content-Disposition: adjunto; filename = b1af9b34-28cc-4479-a056-8c55b41a5ece.txt X-AspNet-Version: 4.0.30319 X-Powered-By: ASP.NET Fecha: jue, 23 dic 2010 21:51:58 GMT
* Home
* Hotels
* Reviews
* Community
* Travel Guide
* Travel Insurance
* Contact us
* FIDDLER: RawDisplay truncado a 128 caracteres. Haga clic derecho para deshabilitar el truncamiento. * *