This commit is contained in:
JORGE LUIS CAUDILLO ESPARZA
2020-05-12 14:14:56 -07:00
parent 2ef099cf27
commit 7a18d716b2
6 changed files with 451 additions and 125 deletions

57
Ashx/SigFiles.ashx Normal file
View File

@@ -0,0 +1,57 @@
<%@ WebHandler Language="C#" Class="SigFiles" %>
using System;
using System.Web;
using Extensiones;
public class SigFiles : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
//context.Response.ContentType = "text/plain";
//context.Response.Write("Hello World");
string path = "";
if (context.Request["FileUrl"] != null)
{
path = string.Format("{0}{1}", ModExtensiones.DirectorioBaseEmpresas, context.Request["FileUrl"]);
try
{
if (System.IO.File.Exists(path))
{
System.IO.FileInfo file = new System.IO.FileInfo(path);
string mimeType = "text/plain";
try
{
mimeType = MimeMapping.GetMimeMapping(path);
}
catch (Exception) { }//si truena no existe el arhivo
context.Response.Clear();
context.Response.ClearHeaders();
context.Response.ClearContent();
context.Response.AddHeader("Content-Disposition", $"attachment; filename= {Uri.EscapeDataString(file.Name)}");
context.Response.AddHeader("Content-Length", file.Length.ToString());
context.Response.ContentType = mimeType;
context.Response.Flush();
context.Response.TransmitFile(file.FullName);
}
}
catch (Exception ex)
{
this.GuardaLog(ex.ToString());
}
}
context.Response.End();
}
public bool IsReusable
{
get
{
return false;
}
}
}