I have a WWW filter on all my actions
public class WwwFilter : ActionFilterAttribute, IActionFilter {
#region IActionFilter Members
void IActionFilter.OnActionExecuted(ActionExecutedContext filterContext) {
}
void IActionFilter.OnActionExecuting(ActionExecutingContext filterContext) {
var request = filterContext.HttpContext.Request;
var response = filterContext.HttpContext.Response;
if (request.Url.Host.StartsWith("www")) {
string newPort = request.Url.IsDefaultPort ? "" : ":" +request.Url.Port.ToString();
string newUrl = request.Url.Scheme + "://" +request.Url.Host.Replace("www.", "") + newPort + request.Url.AbsolutePath;
filterContext.Result = new RedirectResult(newUrl);
}
}
#endregion
}
for my site, http://www.tweetMP.org.au
The www is NOT filtered out for the homepage, or some of the other pages
If you visit around the site using the menu, eventually the www will disappear as the filter kicks in.
I have no idea why this happens. Any ideas?
UPDATE: this appears something to do with the OutputCache on each action I'm doing too. What is the correct way to WWW filter in a medium trust environment?