using System;
using System.Web;

namespace CommunityServer.Components
{
    /// <summary>
    /// CSASPNET20UrlReWriteProvider address a SEO optimization bug in the RewritePath in ASP.NET 2.0.
    /// 
    /// Using the ASP.NET 1.1 overload of RewritePath(string, string, string) many search engines will
    /// recieve a 302 object moved status code. This issue has been confirmed by the Microsoft ASP.NET 
    /// team. To fix this issue in CS 2.x, it is necessary to use the RewritePath overload of
    /// (string, string, string, bool). Unfortunetly, this overload is not available in .NET 1.1. 
    /// 
    /// If no provider is specified in CS, CSUrlReWriter is used. To ease configuration, before declaring
    /// the default type, CS will check to see which verion of HttpContext is used. If the Major version is 
    /// greater than or equal to 2, we will dynamically instantiate the CSASPNET20UrlReWriteProvider instance
    /// instead.
    /// 
    /// This class will disappear in CS 2.2 since we will only be supportting ASP.NET 2.0, we will simply 
    /// update CSUrlReWriter to use the proper overload.
    /// </summary>
    public class CSASPNET20UrlReWriteProvider : CSUrlReWriter
    {
        /// <summary>
        /// Override the CSUrlReWriter instance to call the RewritePath which does not 
        /// causes SEO issues
        /// </summary>
        public override void RewriteUrl(HttpContext context, string path, string queryString)
        {
            context.RewritePath(path, null, queryString,true);
        }
    }
}
