leeres Application_BeginRequest (Gegenstandabsender, EventArgs e)
{
RewriteUrl ();
}
allgemeines DataTable GetVanityLinks ()
{
DatensatzdstVanityLinks = -null;
DataTable dtblVanityLinks = Null;
//dtblVanityLinks = Context.Cache („vanitylinks“);
wenn (dtblVanityLinks == Null)
{
dstVanityLinks = neuer Datensatz ();
dstVanityLinks.ReadXml (Server.MapPath („VanityURLRedirects.xml“));
dtblVanityLinks = dstVanityLinks.Tables [0];
Context.Cache.Insert („vanitylinks“, dtblVanityLinks, neues CacheDependency (Server.MapPath („VanityURLRedirects.xml“)));
}
RückholdtblVanityLinks;
}
Öffentlichkeit leeres RewriteUrl ()
{
DataTable dtblVanityLinks = Null;
SchnurstrThisUrl = -null;
SchnurstrSelect = -null;
DataRow [] arrMatches = Null;
SchnurstrRedirectLink = -null;
dtblVanityLinks = GetVanityLinks ();
strThisUrl = Request.Path.ToLower ();
wenn (Request.ApplicationPath! = „/")
{
strThisUrl = strThisUrl.Remove (0, Request.ApplicationPath.Length);
}
strSelect = „vanitylink = „“ + strThisUrl + „“ „;
arrMatches = dtblVanityLinks.Select (strSelect, „vanitylink“);
wenn (arrMatches.Length > 0)
{
strRedirectLink = arrMatches [0] [„redirectlink“] .ToString (); ;
strRedirectLink = Request.ApplicationPath + strRedirectLink;
Context.RewritePath (strRedirectLink);
}
}
|