/// <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 { SubscriptionModule module = new SubscriptionModule(); 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(); } } }
/// <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.tbx_LicenseDomain.Text = rule.Properties["LicenseDomain"].ToString(); this.txb_LicenseFile.Text = rule.Properties["LicenseFile"].ToString(); } //TODO Button Dialog Update else { try { LicenseModule module = new LicenseModule(); Uri url = new Uri(this.Page.Request.QueryString["Source"].ToString()); if (WebSiteControllerConfig.IsPageControlled(url, module.RuleType)) { System.Collections.Generic.List <WebSiteControllerRule> rules = WebSiteControllerConfig.GetRulesForPage(SPAdministrationWebApplication.Local, url, module.RuleType); WebSiteControllerRule rule = rules[rules.Count - 1]; this.tbx_LicenseDomain.Text = rule.Properties["LicenseDomain"].ToString(); this.txb_LicenseFile.Text = rule.Properties["LicenseFile"].ToString(); } } catch (Exception ex) { ex.ToString(); } } }
void WebSiteControllerModule_OnPreRequestHandlerExecute(object sender, EventArgs e) { LanguageModule module = new LanguageModule(); application = sender as HttpApplication; Uri url = WebSiteControllerModule.GetFullUrl(application.Context); string host_ip = application.Request.UserHostAddress; 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); } }
private void CheckUrlOnZones(SPSite site, Uri curl, out Uri url, out bool isControlled, string RuleType) { Uri zoneUri = curl; isControlled = WebSiteControllerConfig.IsPageControlled(site.WebApplication, zoneUri, RuleType); UriBuilder builder = new UriBuilder(curl); if (!isControlled) { try { zoneUri = site.WebApplication.GetResponseUri(SPUrlZone.Default); builder.Host = zoneUri.Host; builder.Port = zoneUri.Port; isControlled = WebSiteControllerConfig.IsPageControlled(site.WebApplication, builder.Uri, RuleType); zoneUri = builder.Uri; } catch (Exception ex) { ex.ToString(); } } if (!isControlled) { try { zoneUri = site.WebApplication.GetResponseUri(SPUrlZone.Internet); builder.Host = zoneUri.Host; builder.Port = zoneUri.Port; isControlled = WebSiteControllerConfig.IsPageControlled(site.WebApplication, builder.Uri, RuleType); zoneUri = builder.Uri; } catch (Exception ex) { ex.ToString(); } } if (!isControlled) { try { zoneUri = site.WebApplication.GetResponseUri(SPUrlZone.Extranet); builder.Host = zoneUri.Host; builder.Port = zoneUri.Port; isControlled = WebSiteControllerConfig.IsPageControlled(site.WebApplication, builder.Uri, RuleType); zoneUri = builder.Uri; } catch (Exception ex) { ex.ToString(); } } if (!isControlled) { try { zoneUri = site.WebApplication.GetResponseUri(SPUrlZone.Intranet); builder.Host = zoneUri.Host; builder.Port = zoneUri.Port; isControlled = WebSiteControllerConfig.IsPageControlled(site.WebApplication, builder.Uri, RuleType); zoneUri = builder.Uri; } catch (Exception ex) { ex.ToString(); } } if (!isControlled) { try { zoneUri = site.WebApplication.GetResponseUri(SPUrlZone.Custom); builder.Host = zoneUri.Host; builder.Port = zoneUri.Port; isControlled = WebSiteControllerConfig.IsPageControlled(site.WebApplication, builder.Uri, RuleType); zoneUri = builder.Uri; } catch (Exception ex) { ex.ToString(); } } if (!isControlled) { Uri altZone = null; foreach (SPAlternateUrl altUrl in site.WebApplication.AlternateUrls) { if (altUrl.UrlZone == site.Zone) { altZone = altUrl.Uri; break; } } if (altZone != null) { builder.Host = zoneUri.Host; builder.Port = zoneUri.Port; isControlled = WebSiteControllerConfig.IsPageControlled(site.WebApplication, builder.Uri, RuleType); zoneUri = builder.Uri; } } url = zoneUri; }