All pastes #90914 Raw Edit

Someone

public text v1 · immutable
#90914 ·published 2006-07-18 03:33 UTC
rendered paste body
<%@ Application Language="C#" %>

<script runat="server">

	void Application_Start(object sender, EventArgs e) 
    {
		SiteMap.SiteMapResolve += new SiteMapResolveEventHandler(AppendQueryString);
		if (!Roles.RoleExists("Administrators")) Roles.CreateRole("Administrators");
        if (!Roles.RoleExists("Staff")) Roles.CreateRole("Staff");
        if (!Roles.RoleExists("Pro-Gamer")) Roles.CreateRole("Pro-Gamer");
        if (!Roles.RoleExists("Gamer")) Roles.CreateRole("Gamer");
                
    }

    void Session_Start(object sender, EventArgs e)
    {
    }

    void Application_End(object sender, EventArgs e)
    {
    }

	SiteMapNode AppendQueryString(object o, SiteMapResolveEventArgs e)
    {
		if (SiteMap.CurrentNode != null) 
        {
			SiteMapNode temp;
			temp = SiteMap.CurrentNode.Clone(true);
			Uri u = new Uri(e.Context.Request.Url.ToString());
			temp.Url += u.Query;
			if (temp.ParentNode != null) 
            {
				temp.ParentNode.Url += u.Query;
			}
			return temp;
		} 
        else 
        {
			return null;
		}
	}	
    // HotFix Section
    void Application_BeginRequest(Object sender, EventArgs e)
    {
        System.Data.DataTable dtblBadLinks;
        string strThisUrl;
        string strSelect;
        System.Data.DataRow[] arrMatches;
        string strGoodLink;

        dtblBadLinks = GetBadLinks();
        strThisUrl = Request.Path.ToLower();
        if (Request.ApplicationPath != "/")
        {
            strThisUrl = strThisUrl.Remove(0, Request.ApplicationPath.Length);
        }
        strSelect = "BadLink='" + strThisUrl + "'";
        arrMatches = dtblBadLinks.Select(strSelect, "BadLink");
        if (arrMatches.Length > 0)
        {
            strGoodLink = (string)arrMatches[0]["GoodLink"]; 
            strGoodLink = Request.ApplicationPath + strGoodLink;
            Context.RewritePath(strGoodLink);
        }
    }
    System.Data.DataTable GetBadLinks()
    {
        System.Data.DataSet dstBadLinks;
        System.Data.DataTable dtblBadLinks = (System.Data.DataTable)(Context.Cache["BadLinks"]);

        dtblBadLinks = (System.Data.DataTable)Context.Cache["BadLinks"];
        if (dtblBadLinks == null)
        {
            dstBadLinks = new System.Data.DataSet();
            dstBadLinks.ReadXml(Server.MapPath("~/App_Data/XML/HotFix/BadLinks.xml"));
            dtblBadLinks = dstBadLinks.Tables[0];
            Context.Cache.Insert("BadLinks", dtblBadLinks, new CacheDependency(Server.MapPath("~/App_Data/XML/HotFix/BadLinks.xml")));
        }
        return dtblBadLinks;
    }
</script>