Esempio n. 1
0
        public static void Process()
        {
            URLRewriter oRewriter = (URLRewriter)System.Configuration.ConfigurationManager.GetSection("urlrewrites");

            string zSubst = oRewriter.GetSubstitution(HttpContext.Current.Request.Path);

            if (!string.IsNullOrEmpty(zSubst))
            {
                Logger.InfoFormat("Rewriting url '{0}' to '{1}' ", HttpContext.Current.Request.Path, zSubst);
                HttpContext.Current.RewritePath(zSubst);
            }
        }
Esempio n. 2
0
        protected void Application_BeginRequest(Object sender, EventArgs e)
        {
            /*
             * The URLRewriter was taken from http://www.codeproject.com/aspnet/URLRewriter.asp and modified slightly.
             * It will read the config section called 'urlrewrites' from web.config and process each rule
             * The rules are set of url transformations defined using regular expressions with support for substitutions (the ability to extract regex-matched portions of a string).
             * There is only one rule currenty defined. It rewrites urls like: user/john ->user.aspx?username=john
             */
            // System.Diagnostics.Debugger.Launch();
            Logger.DebugFormat("Processing {0} on {1} ", Request.HttpMethod, stripQueryString(Request.Url));
            if (Request.QueryString.Count > 0)
            {
                Logger.DebugFormat("Querystring follows: \n{0}", ToString(Request.QueryString));
            }
            if (Request.Form.Count > 0)
            {
                Logger.DebugFormat("Posted form follows: \n{0}", ToString(Request.Form));
            }

            URLRewriter.Process();
        }