Friday, November 18, 2011

Creating a Custom HttpHandler in Windows SharePoint

ASP.NET programming supports the creation of custom HttpHandler components, which provide a flexible and efficient way to process requests that don't return standard HTML-based pages. For example, HttpHandler components are great for situations in which you want to return simple text, XML, or binary data to the user.
 
<%@ Assembly Name="Microsoft.SharePoint, [full assembly name]" %> 
<%@ WebHandler Language="C#" Class="HelloHttpHandler" %>
using System;
using System.Web;
using Microsoft.SharePoint;

public class HelloHttpHandler : IHttpHandler {
  public bool IsReusable {
    get { return false; }
  }
  public void ProcessRequest(HttpContext context) {
    SPSite siteColl = SPContext.Current.Site;
    SPWeb site = SPContext.Current.Web;
    context.Response.ContentType = "text/plain"
    context.Response.Write("Hello HttpHandler from the site " +
                           site.Title + 
                           " at " +
                           site.Url);   
  }
}
 

No comments:

Post a Comment

Thank you for Commenting Will reply soon ......

Featured Posts

Open Hardware Monitor A Handy Tool for System Monitoring

#Open #Hardware #Monitor: A Handy Tool for #System #Monitoring #OpenHardwareMonitor is a free, #opensource #software designed to monitor t...