⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 downloadpostattachment.cs

📁 community server 源码
💻 CS
字号:
//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
//     Copyright (c) Telligent Systems Corporation.  All rights reserved.
// </copyright> 
//------------------------------------------------------------------------------

using System.Web;
using System.Web.UI;

using CommunityServer.Components;
using CommunityServer.Discussions.Components;

namespace CommunityServer.Discussions.Controls 
{
    /// <summary>
    /// Summary description for PostAttachment.
    /// </summary>
    public class DownloadPostAttachment : Control 
    {
        CSContext csContext = CSContext.Current;

        protected override void OnLoad(System.EventArgs e)
        {
            // Get the forum the attachment is in
            //
            Forum forum = Forums.GetForumByPostID(csContext.PostID, csContext.User.UserID, false);

            if (forum == null) 
            {
                throw new CSException(CSExceptionType.SectionNotFound, csContext.SectionID.ToString());
            }

            // Get the ForumPermission
            //
            ForumPermission permission = forum.ResolvePermission( csContext.User ) as ForumPermission;

            // if user is not allowed to read this post, return
            //
            if (!permission.Read ) 
            {
                throw new CSException(CSExceptionType.GeneralAccessDenied, csContext.SectionID.ToString());
            }

			ForumAttachmentSettings fas = ForumConfiguration.Instance().AttachmentSettings;
			fas.HandleHttpRequest(this.Context, forum);
            System.Web.HttpContext.Current.Response.End();
        }

    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -