Application_BeginRequest vago (remetente do objeto, EventArgs e)
{
RewriteUrl ();
}
DataTable público GetVanityLinks ()
{
dstVanityLinks = zero da série de dados;
dtblVanityLinks = zero de DataTable;
//dtblVanityLinks = Context.Cache (“vanitylinks”);
se (zero do == dos dtblVanityLinks)
{
dstVanityLinks = série de dados nova ();
dstVanityLinks.ReadXml (Server.MapPath (“VanityURLRedirects.xml”));
dtblVanityLinks = dstVanityLinks.Tables [0];
Context.Cache.Insert (“vanitylinks”, dtblVanityLinks, CacheDependency novo (Server.MapPath (“VanityURLRedirects.xml”)));
}
dtblVanityLinks do retorno;
}
público RewriteUrl vago ()
{
dtblVanityLinks = zero de DataTable;
strThisUrl = zero da corda;
strSelect = zero da corda;
arrMatches = zero de DataRow [];
strRedirectLink = zero da corda;
dtblVanityLinks = GetVanityLinks ();
strThisUrl = Request.Path.ToLower ();
se (Request.ApplicationPath! = “/")
{
strThisUrl = strThisUrl.Remove (0, Request.ApplicationPath.Length);
}
strSelect = “vanitylink = “” + strThisUrl + “” “;
arrMatches = dtblVanityLinks.Select (strSelect, “vanitylink”);
se (arrMatches.Length > 0)
{
strRedirectLink = arrMatches [0] [“redirectlink”] .ToString (); ;
strRedirectLink = Request.ApplicationPath + strRedirectLink;
Context.RewritePath (strRedirectLink);
}
}
|