Ejemplo n.º 1
0
        private static bool IsMatch(string Path, out int RewriteRuleID)
        {
            Regex oReg;
            Match oMatch;
            RewriteRuleID = 0;

            RewriteRuleResponse response = new RewriteRuleResponse();
            using (RewriteRuleServiceClient client = new RewriteRuleServiceClient())
            {
                response = client.GetRewriteRuleByUrl(new RewriteRuleRequest()
                {
                    Url = Path
                });

                client.Close();
            }
            if (response != null && response.RewriteRule != null)
            {
                RewriteRuleID = response.RewriteRule.RewriteRuleId;
            }

            return RewriteRuleID > 0;
        }
Ejemplo n.º 2
0
        public static string GetSubstitution(string path)
        {
            Regex oReg;

            RewriteRuleResponse response = new RewriteRuleResponse();
            using (RewriteRuleServiceClient client = new RewriteRuleServiceClient())
            {
                response = client.GetRewriteRuleByUrl(new RewriteRuleRequest()
                {
                    Url = path
                });

                client.Close();
            }

            if (response != null && response.RewriteRule != null && response.RewriteRule.RewriteRuleId > 0)
            {
                oReg = new Regex(response.RewriteRule.Url);
                return oReg.Replace(path, response.RewriteRule.Rewrite);
            }

            return path;
        }