📄 avatarhttphandler.cs
字号:
//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
// Copyright (c) Telligent Systems Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
// 修改说明:如果头像保存在磁盘,则直接显示磁盘上的图片
// 修改人:宝玉
// 修改日期:2005-06-13
using System;
using System.Web;
using System.Web.Caching;
using CommunityServer;
using CommunityServer.Configuration;
namespace CommunityServer.Components.HttpHandler {
public class AvatarHttpHandler : IHttpHandler {
public void ProcessRequest (HttpContext context) {
try {
Avatar userAvatar = Resources.GetAvatar( int.Parse(context.Request.QueryString["UserID"]) );
// 如果是保存在磁盘上
//
if (userAvatar.ImageID == 0)
{
context.Response.Redirect( CSConfiguration.GetConfig().AvatarsPath + userAvatar.FileName, true);
}
context.Response.ContentType = userAvatar.ContentType;
context.Response.OutputStream.Write(userAvatar.Content, 0, userAvatar.Length);
context.Response.Cache.SetCacheability(HttpCacheability.Public);
// Terry Denham 7/16/2004
// changing default cache for avatars from 1 day to 30 minutes
context.Response.Cache.SetExpires(DateTime.Now.AddMinutes(30));
context.Response.Cache.SetAllowResponseInBrowserHistory(true);
context.Response.Cache.SetValidUntilExpires(true);
context.Response.Cache.VaryByParams["UserID"] = true;
} catch {}
}
public bool IsReusable {
get {
return false;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -