/// <summary> /// Attaches to appropriate request pipeline events /// </summary> /// <param name="pageControllerModule">The WebSiteControllerModule whose event the module can attach to</param> public void Init(WebSiteControllerModule WebSiteControllerModule) { WebSiteControllerModule.OnAcquireRequestState += new EventHandler(WebSiteControllerModule_OnAcquireRequestState); WebSiteControllerModule.OnEndRequest += new EventHandler(WebSiteControllerModule_OnEndRequest); WebSiteControllerModule.OnPreRequestHandlerExecute += new EventHandler(WebSiteControllerModule_OnPreRequestHandlerExecute); WebSiteControllerModule.OnBeginRequest += new EventHandler(WebSiteControllerModule_OnBeginRequest); WebSiteControllerModule.OnAuthenticateRequest += new EventHandler(WebSiteControllerModule_OnAuthenticateRequest); }
/// <summary> /// Attaches to appropriate request pipeline events /// </summary> /// <param name="pageControllerModule">The PageControllerModule whose event the module can attach to</param> public void Init(WebSiteControllerModule WebSiteControllerModule) { WebSiteControllerModule.OnAuthenticateRequest += new EventHandler(WebSiteControllerModule_OnAuthenticateRequest); WebSiteControllerModule.OnAuthorizeRequest += new EventHandler(WebSiteControllerModule_OnAuthorizeRequest); WebSiteControllerModule.OnError += new EventHandler(WebSiteControllerModule_OnError); WebSiteControllerModule.OnEndRequest += new EventHandler(WebSiteControllerModule_OnEndRequest); WebSiteControllerModule.OnBeginRequest += new EventHandler(WebSiteControllerModule_OnBeginRequest); }
/// <summary> /// Attaches to appropriate request pipeline events /// </summary> /// <param name="pageControllerModule">The PageControllerModule whose event the module can attach to</param> public void Init(WebSiteControllerModule WebSiteControllerModule) { WebSiteControllerModule.OnPreRequestHandlerExecute += new EventHandler(WebSiteControllerModule_OnPreRequestHandlerExecute); WebSiteControllerModule.OnBeginRequest += new EventHandler(WebSiteControllerModule_OnBeginRequest); WebSiteControllerModule.OnPreSendRequestHeaders += new EventHandler(WebSiteControllerModule_OnPreSendRequestHeaders); WebSiteControllerModule.OnEndRequest += new EventHandler(WebSiteControllerModule_OnEndRequest); WebSiteControllerModule.OnPostRequestHandlerExecute += new EventHandler(WebSiteControllerModule_OnPostRequestHandlerExecute); WebSiteControllerModule.OnPostReleaseRequestState += new EventHandler(WebSiteControllerModule_OnPostReleaseRequestState); }
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); } }
/// <summary> /// Attaches to appropriate request pipeline events /// </summary> /// <param name="pageControllerModule">The PageControllerModule whose event the module can attach to</param> public void Init(WebSiteControllerModule WebSiteControllerModule) { //WebSiteControllerModule.OnBeginRequest += new EventHandler(WebSiteControllerModule_OnBeginRequest); }
/// <summary> /// Attaches to appropriate request pipeline events /// </summary> /// <param name="pageControllerModule">The PageControllerModule whose event the module can attach to</param> public void Init(WebSiteControllerModule WebSiteControllerModule) { //WebSiteControllerModule.OnPostMapRequestHandler += new EventHandler(WebSiteControllerModule_OnPostMapRequestHandler); //WebSiteControllerModule.OnPostAcquireRequestState += new EventHandler(WebSiteControllerModule_OnPostAcquireRequestState); //WebSiteControllerModule.OnPreRequestHandlerExecute += new EventHandler(WebSiteControllerModule_OnPreRequestHandlerExecute); }
/// <summary> /// Attaches to appropriate request pipeline events /// </summary> /// <param name="pageControllerModule">The PageControllerModule whose event the module can attach to</param> public void Init(WebSiteControllerModule WebSiteControllerModule) { WebSiteControllerModule.OnPreSendRequestContent += new EventHandler(WebSiteControllerModule_OnPreSendRequestContent); }
private void ProcessRequest(Object sender, EventArgs e) { //SemanticModule module = new SemanticModule(); application = sender as HttpApplication; HttpContext context = application.Context; Uri url = WebSiteControllerModule.GetFullUrl(application.Context); if (url == null || url.AbsoluteUri.EndsWith("null")) { return; } /* * else * { * if (url.DnsSafeHost == "clubcloud.kampong.nl") * { * System.UriBuilder builder = new UriBuilder(url); * builder.Host = "kampong.clubcloud.nl"; * string newurl = builder.ToString(); * * try * { * context.RewritePath(builder.ToString()); * } * catch(Exception ex) * { * ex.ToString(); * //context.Response.Redirect(builder.ToString()); * } * * } * } */ GateKeeperSettings gatekeeper = new GateKeeperSettings(); gatekeeper = gatekeeper.Load(); if (url.OriginalString.ToLower().Contains(gatekeeper.HoneyPotPath.ToLower()) && !string.IsNullOrEmpty(gatekeeper.HoneyPotPath)) { return; } if (url.OriginalString.ToLower().Contains("_layouts") || url.OriginalString.ToLower().Contains("_login") || url.OriginalString.ToLower().Contains("_vti_bin") || url.OriginalString.ToLower().Contains("_catalogs") || url.OriginalString.ToLower().Contains("_windows") || url.OriginalString.ToLower().Contains("_forms") || url.OriginalString.ToLower().Contains("_trust")) { return; } try { bool handled = false; #region Controlled bool isControlled = false; using (SPSite site = new SPSite(url.OriginalString)) { CheckUrlOnZones(site, url, out url, out isControlled); } if (isControlled) { using (SPSite site = new SPSite(url.OriginalString)) { System.Collections.Generic.List <WebSiteControllerRule> rules = WebSiteControllerConfig.GetRulesForPage(site.WebApplication, url, this.RuleType); WebSiteControllerRule rule = null; foreach (WebSiteControllerRule arule in rules) { if (arule.RuleType == this.RuleType && arule.Properties.ContainsKey("OriginalUrl")) { if (arule.Url.ToLower() == url.ToString().ToLower() && !arule.IsDisabled) { rule = arule; break; } } } if (rule != null) { //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); } if (OriginalUrl.IndexOf(".aspx") >= 1) { if (CheckIfExists(OriginalUrl, url)) { application.Context.RewritePath("~/" + welcomepage); } else { application.Server.ClearError(); application.Response.StatusCode = (int)HttpStatusCode.NotFound; throw (new HttpException((int)HttpStatusCode.NotFound, "")); } } //application.Context.RewritePath("~/" + OriginalUrl); handled = true; } else { handled = false; } } } #endregion if (!handled) { if (!application.Context.Request.Url.LocalPath.Contains(".")) { //if (url.LocalPath.IndexOf(".aspx") >= 1) //{ if (CheckIfExists(url.AbsolutePath, url)) { if (islist) { //SPBasePermissions locked = (SPBasePermissions.ViewListItems | SPBasePermissions.Open | SPBasePermissions.ViewPages | SPBasePermissions.UseClientIntegration); //SPBasePermissions permission = site.OpenWeb().AnonymousPermMask64; //if ((locked != permission) || context.User.Identity.IsAuthenticated) //{ application.Context.Response.Redirect("~/" + welcomepage, false); //} //else //{ // application.Server.ClearError(); // application.Response.StatusCode = (int)HttpStatusCode.NotFound; // throw (new HttpException((int)HttpStatusCode.NotFound, "")); //} } else { if (isweb) { try { //application.Context.RewritePath("~/" + site.RootWeb.RootFolder.WelcomePage); //SPWeb cweb = SPContext.Current.Web; //SPFolder croot = cweb.RootFolder; //string cwelcome = croot.WelcomePage; //SPSecurity.RunWithElevatedPrivileges(delegate() //{ using (SPSite site = new SPSite(url.OriginalString)) { using (SPWeb web = site.OpenWeb()) { SPFolder root = web.RootFolder; string welcomepage = string.Empty; if (root.Exists) { welcomepage = root.WelcomePage; } else { welcomepage = web.RootFolder.WelcomePage; } if (issubcollection) { welcomepage = SPUtility.ConcatUrls(web.ServerRelativeUrl, welcomepage); } application.Context.RewritePath("~/" + welcomepage); } } //}); } catch (Exception ex) { SPDiagnosticsService.Local.WriteTrace(0, new SPDiagnosticsCategory(ex.Source, TraceSeverity.High, EventSeverity.Error), TraceSeverity.High, ex.Message, ex.Data); application.Context.RewritePath("~/" + welcomepage); } } else { application.Context.RewritePath("~/" + welcomepage); } } } else { //TODO Catch SharePoint Designer requests. if (SPContext.Current == null) { string useragent = application.Request.UserAgent; if (useragent == "Microsoft Office Protocol Discovery") { return; } application.Server.ClearError(); application.Response.StatusCode = (int)HttpStatusCode.NotFound; throw (new HttpException((int)HttpStatusCode.NotFound, "")); //return; } else { application.Server.ClearError(); application.Response.StatusCode = (int)HttpStatusCode.NotFound; throw (new HttpException((int)HttpStatusCode.NotFound, "")); } } //} } else { if (url.LocalPath.IndexOf(".aspx") >= 1) { if (!CheckIfExists(url.AbsolutePath, url)) { application.Server.ClearError(); application.Response.StatusCode = (int)HttpStatusCode.NotFound; throw (new HttpException((int)HttpStatusCode.NotFound, "")); } else { if ((url.AbsolutePath != welcomepage) && (url.AbsolutePath != "/" + welcomepage)) { application.Context.RewritePath("~/" + welcomepage, true); } } } /* * else * { * if (url.IsFile) * { * application.Server.ClearError(); * application.Response.StatusCode = (int)HttpStatusCode.NotFound; * throw (new HttpException((int)HttpStatusCode.NotFound, "")); * } * } */ } } } catch (HttpException) { throw; } catch (Exception ex) { SPDiagnosticsService.Local.WriteTrace(0, new SPDiagnosticsCategory(ex.Source, TraceSeverity.High, EventSeverity.Error), TraceSeverity.High, ex.Message, ex.Data); application.Server.ClearError(); application.Response.StatusCode = (int)HttpStatusCode.BadRequest; WebSiteControllerRule rule = WebSiteControllerConfig.GetRule("ErrorCode", "400"); string page = rule.Properties["ErrorPage"].ToString(); context.Response.Redirect("/" + page + "?aspxerrorpath=" + url, false); } finally { } //HttpContext context = application.Context; if (((context != null) && (context.Request != null)) && ((context.Request.Browser != null) && (context.Request.Browser.Adapters != null))) { string fullName = typeof(HtmlForm).FullName; if (!context.Request.Browser.Adapters.Contains(fullName)) { context.Request.Browser.Adapters[fullName] = typeof(WebSiteAdapter).AssemblyQualifiedName; } /* * fullName = typeof(Page).FullName; * if (!context.Request.Browser.Adapters.Contains(fullName)) * { * context.Request.Browser.Adapters[fullName] = typeof(WebSitePage).AssemblyQualifiedName; * } */ } }
/// <summary> /// Attaches to appropriate request pipeline events /// </summary> /// <param name="pageControllerModule">The PageControllerModule whose event the module can attach to</param> public void Init(WebSiteControllerModule WebSiteControllerModule) { }
protected override void OnPreRender(EventArgs e) { try { base.OnPreRender(e); dataSource = this.GetDataSource() as WebSiteDataSource; provider = (dataSource != null) ? dataSource.Provider : null; if (provider == null) { return; } menu = MenuBase.Instantiate(ClientID, ControlType, ControlStyle); menu.ApplySettings( new Settings { ControlType = ControlType, ControlStyle = ControlStyle, NodeXmlPath = NodeXmlPath, NodeSelector = NodeSelector, IncludeContext = IncludeContext, IncludeHidden = IncludeHidden, IncludeNodes = IncludeNodes, ExcludeNodes = ExcludeNodes, NodeManipulator = NodeManipulator, ClientOptions = ClientOptions, TemplateArguments = TemplateArguments }); Uri url = WebSiteControllerModule.GetFullUrl(Context); SPSite site = new SPSite(url.OriginalString); bool isControlled = false; CheckUrlOnZones(site, url, out url, out isControlled); List <WebSiteNode> nodes = new List <WebSiteNode>(); if (isControlled) { WebSiteNode cnode = provider.FindWebSiteNode(url.ToString()); if (cnode != null) { nodes.Add(cnode); } } if (nodes.Count == 0) { List <SemanticUrl> entries = CheckForManagedUrl(site, url); foreach (SemanticUrl surl in entries) { WebSiteNode cnode = provider.FindWebSiteNode(surl.Semantic); if (cnode != null) { nodes.Add(cnode); } } //urlnode = provider.FindWebSiteNode(Context.Request.Url.ToString()); } WebSiteNode root = (WebSiteNode)provider.RootNode.Clone(); if (provider.CurrentNode != null) { root.FindById(provider.CurrentNode.Id).Selected = false; } else { RemoveSelectedNodes(ref root); } if (nodes.Count > 0)// != null) { foreach (WebSiteNode node in nodes) { root.FindById(node.Id).Selected = true; } /* * if (nodes.Count == 1) * { * root.CurrentNode = nodes[0]; * } */ } else { root.Selected = true; } //provider.ResetProvider(); menu.RootNode = root;// provider.RootNode; menu.PreRender(this.Page); } catch (Exception exc) { exc.ToString(); } }