Advertisement
Guest User

TehOne

a guest
Aug 30th, 2010
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.23 KB | None | 0 0
  1. using System;
  2. using System.Web;
  3. using Microsoft.SharePoint;
  4. using Microsoft.SharePoint.Publishing;
  5. using System.Web.Caching;
  6.  
  7. namespace MyTestSharePoint.WebHandlers
  8. {
  9.     public class TestMyTestArticleHandler : IHttpHandler
  10.     {
  11.         bool HasErrors = false;
  12.         Cache Cache;
  13.         HttpRequest Request;
  14.         HttpResponse Response;
  15.         SPSite CurrentSite;
  16.         SPWeb CurrentWeb;
  17.  
  18.         public bool IsReusable
  19.         {
  20.             get { return false; }
  21.         }
  22.  
  23.         public void ProcessRequest(HttpContext context)
  24.         {
  25.             this.Cache = context.Cache;
  26.             this.Request = context.Request;
  27.             this.Response = context.Response;
  28.  
  29.             Response.Cache.SetCacheability(HttpCacheability.NoCache);
  30.             Response.Cache.SetNoStore();
  31.             Response.Cache.SetExpires(DateTime.MinValue);
  32.  
  33.             try
  34.             {
  35.                 this.CurrentSite = SPContext.Current.Site;
  36.                 this.CurrentWeb = SPContext.Current.Web;
  37.  
  38.                 string pagePath = Request.UrlReferrer.AbsolutePath;
  39.                 string pageName = pagePath.Substring(pagePath.LastIndexOf('/') + 1);
  40.  
  41.                 Response.Write("pageName: " + pageName);
  42.             }
  43.             catch (Exception ex)
  44.             {
  45.                 Response.Write("Exception: " + ex.ToString());
  46.  
  47.                 if (ex.InnerException != null)
  48.                     Response.Write("InnerException: " + ex.InnerException.ToString());
  49.             }
  50.  
  51.         }
  52.     }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement