public void DeleteTempFIle(string FILENAME) { //get Authorization header HttpContext httpContext = HttpContext.Current; string authHeader = httpContext.Request.Headers["Authorization"]; Response auth = Controller.ControllerCheckIn.CheckLogIn_forProcess(authHeader); if (auth.Message != "") { Context.Response.Clear(); Context.Response.ContentType = "application/json"; Context.Response.Flush(); Context.Response.Write(JsonConvert.SerializeObject(auth)); Context.Response.End(); } else { ControllerFiles fileService = new ControllerFiles(); Response response = fileService.DeleteTempFile(FILENAME); Context.Response.Clear(); Context.Response.ContentType = "application/json"; Context.Response.Flush(); Context.Response.Write(JsonConvert.SerializeObject(response)); Context.Response.End(); } }
public void GetTempFile(string FILENAME) { //get Authorization header HttpContext httpContext = HttpContext.Current; string authHeader = httpContext.Request.Headers["Authorization"]; Response auth = Controller.ControllerCheckIn.CheckLogIn_forProcess(authHeader); if (auth.Message != "") { Context.Response.Clear(); Context.Response.ContentType = "application/json"; Context.Response.Flush(); Context.Response.Write(JsonConvert.SerializeObject(auth)); Context.Response.End(); } else { ControllerFiles fileService = new ControllerFiles(); byte[] file = fileService.GetTempFile(FILENAME); Context.Response.Clear(); Context.Response.ClearHeaders(); Context.Response.ContentType = "application/pdf";; Context.Response.AddHeader("Content-Disposition", "attachment; filename=\"" + FILENAME + "\""); Context.Response.AddHeader("Content-Length", file.Length.ToString()); Context.Response.OutputStream.Write(file, 0, file.Length); Context.Response.Flush(); Context.Response.End(); } }