BlogEngine.Core.Web.HttpHandlers.FileHandler.ProcessRequest C# (CSharp) Метод

ProcessRequest() публичный Метод

Enables processing of HTTP Web requests by a custom HttpHandler that implements the interface.
public ProcessRequest ( HttpContext context ) : void
context System.Web.HttpContext /// An /// object that provides references to the intrinsic server objects /// (for example, Request, Response, Session, and Server) used to service HTTP requests. ///
Результат void
        public void ProcessRequest(HttpContext context)
        {
            if (!string.IsNullOrEmpty(context.Request.QueryString["file"]))
            {
                var fileName = context.Request.QueryString["file"];
                OnServing(fileName);
                fileName = !fileName.StartsWith("/") ? string.Format("/{0}", fileName) : fileName;
                try
                {

                    var file = BlogService.GetFile(string.Format("{0}files{1}",Blog.CurrentInstance.StorageLocation, fileName));
                    if (file != null)
                    {
                        context.Response.AppendHeader("Content-Disposition", string.Format("inline; filename=\"{0}\"", file.Name));
                        SetContentType(context, file.Name);
                        if (Utils.SetConditionalGetHeaders(file.DateCreated.ToUniversalTime()))
                            return;

                        context.Response.BinaryWrite(file.FileContents);
                        OnServed(fileName);
                    }
                    else
                    {
                        OnBadRequest(fileName);
                        context.Response.Redirect(string.Format("{0}error404.aspx", Utils.AbsoluteWebRoot));
                    }
                }
                catch (Exception)
                {
                    OnBadRequest(fileName);
                    context.Response.Redirect(string.Format("{0}error404.aspx", Utils.AbsoluteWebRoot));
                }
            }
        }