日期:2014-05-18 浏览次数:20387 次
public class UserPictureHandler : IHttpHandler { private const string WaterMarkURL = "~/images/WaterMark.png"; public void ProcessRequest (HttpContext context) { Image UserHead = Image.FromFile(context.Request.PhysicalPath); Image WaterMark = Image.FromFile(context.Request.MapPath(WaterMarkURL)); Graphics g = Graphics.FromImage(UserHead); g.DrawImage(WaterMark, new Point(UserHead.Width - WaterMark.Width, UserHead.Height - WaterMark.Height)); g.Dispose(); WaterMark.Dispose(); context.Response.ContentType = "image/Gif"; UserHead.Save(context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Gif); UserHead.Dispose(); context.Response.End(); } public bool IsReusable { get { return false; } } }
<httpHandlers> <remove verb="*" path="*.asmx"/> <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/> <add verb="*" path="images/Users/*.gif" type="UserPictureHandler"/><!--就是这个配置--> </httpHandlers>
<httpHandlers> <add path="interface.sample" verb="*" type="UserPictureHandler"/> <add path="Reserved.ReportViewerWebControl.axd" verb="*" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" validate="false"/> </httpHandlers>