Não foi possível abrir a caixa de diálogo de salvamento do download
Usando o código abaixo, não consigo mostrar a caixa de diálogo abrir / salvar como arquivo:
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();
}
}
Eu tentei fechar a resposta, deixar a resposta em aberto, usarTrasmitFile()
, mas nunca recebo nenhum diálogo ou feedback de qualquer natureza. Eu tentei depurar também, mas nenhuma exceção está sendo lançada. Tentei no IE 7/8 e no Chrome. Qualquer ajuda é apreciada.
Obrigado!
Abaixo está a saída do Fiddler:
HTTP / 1.1 200 OK Controle de cache: privado Comprimento do conteúdo: 3813 Tipo de conteúdo: application / octet-stream Servidor: Microsoft-IIS / 7.5 Disposição de conteúdo: anexo; filename = b1af9b34-28cc-4479-a056-8c55b41a5ece.txt Versão X-AspNet: 4.0.30319 Fornecido por X: ASP.NET Data: quinta-feira, 23 dez 2010 21:51:58 GMT
* Home
* Hotels
* Reviews
* Community
* Travel Guide
* Travel Insurance
* Contact us
* FIDDLER: RawDisplay truncado em 128 caracteres. Clique com o botão direito do mouse para desativar o truncamento. *