Jean Paul's Blog

There are 2 types of People in the World, One who Likes SharePoint and..

  • Microsoft MVP

  • MindCracker MVP

  • CodeProject MVP

  • eBook on SharePoint 2010

  • eBook on Design Patterns

  • eBook on Windows Azure

  • NLayers Framework @ CodePlex

  • MSDN Forums

  • .Net vs. Java

    Due to Public Demand
  • Advertisements

SharePoint & Http Module Example

Posted by Paul on October 30, 2014

In this article I would like to take you through deploying Http Module in SharePoint 2013.


Redirect users from accessing the Site Contents page (viewlsts.aspx)


Open Visual Studio and create a Class Library project.


Add reference to System.Web library.


Replace the class file with following code where:

  • Class implements the IHttpModule interface
  • URL redirection for viewlsts.aspx to

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using System.Web.UI;

namespace SPModule
    public class SPModule : IHttpModule
        public void Dispose()

        public void Init(HttpApplication context)
            context.PreRequestHandlerExecute += context_PreRequestHandlerExecute;

        void context_PreRequestHandlerExecute(object sender, EventArgs e)
            HttpApplication app = sender as HttpApplication;

            if (app != null)
                Page page = app.Context.CurrentHandler as Page;

                if (page != null)
                    if (HttpContext.Current.Request.Url.AbsoluteUri.Contains(“_layouts/15/viewlsts.aspx”))

Build the code & Copy the DLL to IIS SharePoint BIN folder as shown below.


Now open the web.config and find the modules section.  (Please note that there is another httpModules section which is not for our purpose)


Add your class name in the format Assembly.ClassName.  Save changes.

Refresh your SharePoint site and try accessing the viewlsts.aspx page using URL given below.


You should see the page is redirected to




In this article we have seen how to use HTTP Module within SharePoint.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s