Ejemplo n.º 1
0
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                if (!MailPage.IsTurnOnAttachmentsGroupOperations())
                {
                    throw new Exception("Operation is turned off.");
                }

                context.Response.ContentType = "application/octet-stream";
                context.Response.Charset     = Encoding.UTF8.WebName;

                int message_id = Convert.ToInt32(context.Request.QueryString["messageid"]);

                DownloadAllZipped(message_id, context);
            }
            catch (Exception)
            {
                context.Response.Redirect("404.html");
            }
            finally
            {
                context.Response.End();
            }
        }
        public void ProcessRequest(HttpContext context)
        {
            var log = LogManager.GetLogger("ASC.Mail.DownloadAllHandler");

            try
            {
                if (!SecurityContext.IsAuthenticated)
                {
                    throw new HttpException(403, "Access denied.");
                }

                if (!MailPage.IsTurnOnAttachmentsGroupOperations())
                {
                    throw new Exception("Operation is turned off.");
                }

                context.Response.ContentType = "application/octet-stream";
                context.Response.Charset     = Encoding.UTF8.WebName;

                var messageId = Convert.ToInt32(context.Request.QueryString["messageid"]);

                DownloadAllZipped(messageId, context);
            }
            catch (HttpException he)
            {
                log.Error("DownloadAll handler failed", he);

                context.Response.StatusCode = he.GetHttpCode();
                context.Response.Write(he.Message != null ? HttpUtility.HtmlEncode(he.Message) : MailApiErrorsResource.ErrorInternalServer);
            }
            catch (Exception ex)
            {
                log.Error("DownloadAll handler failed", ex);

                context.Response.StatusCode = 404;
                context.Response.Redirect("404.html");
            }
            finally
            {
                try
                {
                    context.Response.Flush();
                    context.Response.SuppressContent = true;
                    context.ApplicationInstance.CompleteRequest();
                }
                catch (HttpException ex)
                {
                    LogManager.GetLogger("ASC").Error("ResponceContactPhotoUrl", ex);
                }
            }
        }