kawitacyjny Application_BeginRequest (Przedmiot nadawca, EventArgs e)
{
RewriteUrl ();
}
jawny DataTable GetVanityLinks ()
{
DataSet dstVanityLinks = null;
DataTable dtblVanityLinks = null;
//dtblVanityLinks = Context.Cache ("vanitylinks");
jeżeli (dtblVanityLinks == null)
{
dstVanityLinks = nowy DataSet ();
dstVanityLinks.ReadXml (Server.MapPath ("VanityURLRedirects.xml"));
dtblVanityLinks = dstVanityLinks.Tables [(0)];
Context.Cache.Insert ("vanitylinks", dtblVanityLinks, nowy CacheDependency (Server.MapPath ("VanityURLRedirects.xml")));
}
powrotny dtblVanityLinks;
}
jawny kawitacyjny RewriteUrl ()
{
DataTable dtblVanityLinks = null;
smyczkowy strThisUrl = null;
smyczkowy strSelect = null;
DataRow [] arrMatches = null;
smyczkowy strRedirectLink = null;
dtblVanityLinks = GetVanityLinks ();
strThisUrl = Request.Path.ToLower ();
jeżeli (Request.ApplicationPath! = "/")
{
strThisUrl = strThisUrl.Remove ((0), Request.ApplicationPath.Length);
}
strSelect = "vanitylink = "" + strThisUrl + "" ";
arrMatches = dtblVanityLinks.Select (strSelect, "vanitylink");
jeżeli (arrMatches.Length > (0))
{
strRedirectLink = arrMatches [(0)] ["redirectlink"] .ToString (); ;
strRedirectLink = Request.ApplicationPath + strRedirectLink;
Context.RewritePath (strRedirectLink);
}
}
|