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

by aboo bolaky 4. December 2010 21:48

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.

Tags: ,

.Net | Applications | Sitecore | Tips & Tricks

Comments

12/8/2010 9:19:12 AM #

pingback

Pingback from topsy.com

Twitter Trackbacks for
        
        IIS 7.5 Logging with Sitecore 6.x in Integrated Pipeline Mode
        [bolaky.net]
        on Topsy.com

topsy.com |

10/28/2011 11:20:41 PM #

pingback

Pingback from sitecorebasics.wordpress.com

Challenges faced during up-gradation of Sitecore instance from IIS 6.0 to IIS 7.5 « Sitecore basics!

sitecorebasics.wordpress.com |

11/5/2011 1:51:39 AM #

Como Conquistar A Un Hombre virgo

very impressionant information thank you

Como Conquistar A Un Hombre virgo Spain |

11/7/2011 2:57:13 PM #

Guide Marrakech

Woh I like your satisfy , saved to darlings ! .

Guide Marrakech France |

11/13/2011 2:14:43 PM #

voir Marrakech

Exceedingly interesting info !Refine right what I was searching for!

voir Marrakech France |

11/16/2011 5:54:17 AM #

immobilier maroc marrakech

Thanks for the auspicious writeup. It really was previously a satisfaction record it. Skim manifold to widely delivered appealing from you! Yet, how can we restrain up a agreement?

immobilier maroc marrakech France |

Tag cloud

Flash Player 9 required.

About Me

I wish I could write something here..
//TODO: ElaborateMe