Quantcast
Channel: < I runat="server" / >
Viewing all articles
Browse latest Browse all 10

IIS 7.5 Logging with Sitecore 6.x in Integrated Pipeline Mode

$
0
0

When you run Sitecore 6.x in Integrated Pipeline Mode, You will notice that ALL IIS log entries contain the log entry for the resquest to the layout (aspx) page (instead of the actual sitecore item .e.g /ContactUs.aspx).

This problem is partly related to another issue outlined on Stack Overflow  [http://stackoverflow.com/questions/353541/iis7-rewritepath-and-iis-log-files]

If you run Sitecore in Classic Mode, the problem disappears. However, if you still wish to use Integrated Pipeline Mode, you will have to intercept the request  before the Sitecore HttpModule (Sitecore.Nexus.dll) gets involved.

Solution

Create a class that extends System.Web.IHttpModule  and  set the path back to the original value after the request has been processed but before the IIS logging module writes the log entry.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;

namespace Test
{
    public class RewritePath : IHttpModule
    {
        public void Init(HttpApplication context)
        {
            context.BeginRequest += OnBeginRequest;
            context.LogRequest += OnEndRequest;
        }

        static void OnBeginRequest(object sender, EventArgs e)
        {
            var app = (HttpApplication)sender;
            app.Context.Items["OriginalPath"] = app.Context.Request.Path;
        }

        static void OnEndRequest(object sender, EventArgs e)
        {
            var app = (HttpApplication)sender;
            var originalPath = app.Context.Items["OriginalPath"] as string;
            if (originalPath != null)
            {
                app.Context.RewritePath(originalPath);
            }
        }

        public void Dispose()
        {

        }

    }
}

Locate the Modules Section (under system.webServer ..remember we’re running in Integrated Pipeline Mode) and plug the module in BEFORE the Sitecore Nexus HttpModule

 

Here's what's captured when everything is compiled and deployed

 

Thanks Sitecore Support.


Viewing all articles
Browse latest Browse all 10

Trending Articles