Ejemplo n.º 1
0
        /// <summary>
        /// Raises the <see cref="E:Load"/> event.
        /// </summary>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected override void OnLoad(EventArgs e)
        {
            SPContext.Current.Web.AllowUnsafeUpdates = true;
            if (!String.IsNullOrEmpty(Request.QueryString["guid"]) && !IsPostBack)
            {
                WebSiteControllerRule rule = WebSiteControllerConfig.GetRule(this.Page.Request.QueryString["guid"]);
                //this.OriginalUrlTextBox.Text = rule.Properties["OriginalUrl"].ToString();
                //this.SemanticUrlTextBox.Text = rule.Properties["SemanticUrl"].ToString();
            }
            //TODO Button Dialog Update
            else
            {
                try
                {
                    AccesModule module = new AccesModule();
                    Uri         url    = new Uri(this.Page.Request.QueryString["Source"].ToString());

                    if (WebSiteControllerConfig.IsPageControlled(url, module.RuleType))
                    {
                        System.Collections.Generic.List <WebSiteControllerRule> rules = WebSiteControllerConfig.GetRulesForPage(SPContext.Current.Site.WebApplication, url, module.RuleType);
                        WebSiteControllerRule rule = rules[rules.Count - 1];
                        //this.OriginalUrlTextBox.Text = rule.Properties["OriginalUrl"].ToString();
                        //this.SemanticUrlTextBox.Text = rule.Properties["SemanticUrl"].ToString();
                    }
                }
                catch (Exception ex)
                {
                    ex.ToString();
                }
            }
        }
Ejemplo n.º 2
0
        private void WebSiteControllerModule_OnBeginRequest(object sender, EventArgs e)
        {
            AccesModule module = new AccesModule();

            application = sender as HttpApplication;
            Uri url = WebSiteControllerModule.GetFullUrl(application.Context);

            if (WebSiteControllerConfig.IsPageControlled(url, module.RuleType))
            {
                System.Collections.Generic.List <WebSiteControllerRule> rules = WebSiteControllerConfig.GetRulesForPage(SPContext.Current.Site.WebApplication, url, module.RuleType);
                WebSiteControllerRule rule = rules[rules.Count - 1];
                string OriginalUrl         = rule.Properties["OriginalUrl"].ToString();

                string httpsAdjustedUrl = rule.Url;
                if (url.ToString().StartsWith("https:", StringComparison.InvariantCultureIgnoreCase))
                {
                    httpsAdjustedUrl = httpsAdjustedUrl.Replace("http", "https");
                }

                Match match = new Regex(httpsAdjustedUrl).Match(url.ToString());
                if (match.Groups.Count > 1)
                {
                    string[] matches = new string[match.Groups.Count - 1];
                    for (int i = 1; i < match.Groups.Count; i++)
                    {
                        matches[i - 1] = match.Groups[i].Value;
                    }

                    OriginalUrl = String.Format(OriginalUrl, matches);
                }

                application.Context.RewritePath(OriginalUrl);
            }
            else
            {
                String NewRule = this.Rewrite(url);
                //WebSiteControllerConfig.AddRule()
                //Forward against the new Rule
                //this.application.Context.RewritePath(NewRule);
            }
        }