A FilterProvider just for the home page

Topics: Writing modules
Apr 24, 2011 at 10:27 PM

I'm creating an OpenID delegation module. It's very simple; it just adds some meta tags to the the HTML of the homepage.

To do this I've created a IResultFilter that inherits from FilterProvider. I've based this on the Google Analytics module. All the work is done in the OnResultExecuting method.

It works, but it adds the meta tags to all the pages of my site.


1. How do I check inside OnResultExecuting to see if the page is the homepage?

2. Is this the best way to add some meta tags to just one page?



May 11, 2011 at 6:42 PM

Hey Richard

You have access to the HttpContext in the filterContext so you could use something like the following to see if the request is for the root of the app.

System.Web.VirtualPathUtility.ToAppRelative(filterContext.HttpContext.Request.Path) == "~/"

It should be fine to add a meta tag this way. The blogs module uses a driver, shape template and placement.info to do something similar. The benefit of the filter is that everything to add the meta tag is in one place.