示例#1
0
        /// <summary>
        /// Render dynamic style sheet file
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult ProtectedDocument(string id)
        {
            try
            {
                var realPath = id.GetUniqueLinkInput();

                // Check if user can access path
                if (_documentService.CanCurrentUserAccessPath(realPath))
                {
                    // Save log
                    _protectedDocumentLogService.SaveProtectedDocumentLog(realPath);

                    // Return file
                    var extension = Path.GetExtension(realPath);
                    if (extension != null)
                    {
                        var mime = System.Web.MimeMapping.GetMimeMapping(extension);
                        return(new FilePathResult(realPath, mime));
                    }
                }
            }
            catch (InvalidUniqueLinkException)
            {
                if (!string.IsNullOrEmpty(id))
                {
                    var fileMime = System.Web.MimeMapping.GetMimeMapping(Path.GetExtension(id));
                    return(new FilePathResult(string.Format("/Documents/{0}", id), fileMime));
                }
            }

            throw new EzCMSNotFoundException();
        }