utan laga kraft Application_BeginRequest (anmärka avsändaren, EventArgs e),
{
RewriteUrl ();
}
offentliga DataTable GetVanityLinks ()
{
DataSetdstVanityLinks = ogiltigt;
DataTable dtblVanityLinks = ogiltigt;
//dtblVanityLinks = Context.Cache (”vanitylinks”);
om (ogiltig dtblVanityLinks==)
{
dstVanityLinks = ny DataSet ();
dstVanityLinks.ReadXml (Server.MapPath (”VanityURLRedirects.xml”));
dtblVanityLinks = dstVanityLinks.Tables [0];
Context.Cache.Insert (”vanitylinks”, dtblVanityLinks, nya CacheDependency (Server.MapPath (”VanityURLRedirects.xml”)));
}
återgånga dtblVanityLinks;
}
offentliga utan laga kraft RewriteUrl ()
{
DataTable dtblVanityLinks = ogiltigt;
stränga strThisUrl = ogiltigt;
stränga strSelect = ogiltigt;
DataRow [] arrMatches = ogiltigt;
stränga strRedirectLink = ogiltigt;
dtblVanityLinks = GetVanityLinks ();
strThisUrl = Request.Path.ToLower ();
om (Request.ApplicationPath! = ”/”)
{
strThisUrl = strThisUrl.Remove (0, Request.ApplicationPath.Length);
}
strSelect = ”vanitylink = ”” + strThisUrl + ”” ”;
arrMatches = dtblVanityLinks.Select (strSelect, ”vanitylink”);
om (arrMatches.Length > 0)
{
strRedirectLink = arrMatches [0] [”redirectlink”] .ToString (); ;
strRedirectLink = Request.ApplicationPath + strRedirectLink;
Context.RewritePath (strRedirectLink);
}
}
|