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

📄 vcardhttphandler.cs

📁 本系统是在asp版《在线文件管理器》的基础上设计制作
💻 CS
字号:
//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
//     Copyright (c) Telligent Systems Corporation.  All rights reserved.
// </copyright> 
//------------------------------------------------------------------------------

using System;
using System.Text;
using System.Web;

namespace CommunityServer.Components.HttpHandler {

    public class VCardHttpHandler : IHttpHandler {

        public void ProcessRequest (HttpContext context) {

            byte[] vcard;


            try {
                // Get the requested user's vcard
                vcard = BuildVCard(context);

                // Set the response type
                context.Response.ContentType = "text/x-vcard";

                // Output the content
                context.Response.OutputStream.Write(vcard, 0, vcard.Length);
                context.Response.End();
            } catch {
                context.Response.Write("Unable to retrieve vcard");
            }


        }

        public byte[] BuildVCard(HttpContext context) 
        {
            StringBuilder vcard = new StringBuilder();
            User user = Users.GetUser(int.Parse(context.Request.QueryString["UserID"]), false, true);

            vcard.Append("BEGIN:VCARD\nVERSION:2.1\n");

            // NickName
            vcard.Append("NICKNAME:" + user.Username + "\n");

            // URL
            //
            vcard.Append("URL;WORK:" + user.Profile.WebAddress + "\n");

            // Title
            vcard.Append("ROLE:" + user.Profile.Occupation + "\n");

            // Email
            vcard.Append("EMAIL;PREF;INTERNET:" + user.Profile.PublicEmail + "\n");

            // End the VCARD
            vcard.Append("\nREV:20030217T210833Z\nEND:VCARD");

            ASCIIEncoding asciiEncoding = new ASCIIEncoding();

            return asciiEncoding.GetBytes(vcard.ToString());

        }

        public bool IsReusable {
            get {
                return false;
            }
        }

    }
}

⌨️ 快捷键说明

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