private void Perform_Search_Engine_Robot_Checks(Navigation_Object CurrentModeCheck, NameValueCollection QueryString)
{
// Some writers should not be selected yet
if ((CurrentModeCheck.Writer_Type != Writer_Type_Enum.HTML) && (CurrentModeCheck.Writer_Type != Writer_Type_Enum.HTML_Echo) && (CurrentModeCheck.Writer_Type != Writer_Type_Enum.OAI))
{
HttpContext.Current.Response.Status = "301 Moved Permanently";
HttpContext.Current.Response.AddHeader("Location", CurrentModeCheck.Base_URL);
HttpContext.Current.ApplicationInstance.CompleteRequest();
currentMode.Request_Completed = true;
return;
}
// There are some spots which robots are never allowed to go, just
// by virtue of the fact they don't logon
if ((CurrentModeCheck.Mode == Display_Mode_Enum.Internal) || (CurrentModeCheck.Mode == Display_Mode_Enum.My_Sobek) || (CurrentModeCheck.Mode == Display_Mode_Enum.Administrative) || (CurrentModeCheck.Mode == Display_Mode_Enum.Reset) || (CurrentModeCheck.Mode == Display_Mode_Enum.Item_Cache_Reload) || (CurrentModeCheck.Mode == Display_Mode_Enum.Results) || (CurrentModeCheck.Mode == Display_Mode_Enum.Public_Folder) || ((CurrentModeCheck.Mode == Display_Mode_Enum.Aggregation) && (CurrentModeCheck.Aggregation_Type == Aggregation_Type_Enum.Browse_By)) || (CurrentModeCheck.Mode == Display_Mode_Enum.Item_Print))
{
HttpContext.Current.Response.Status = "301 Moved Permanently";
HttpContext.Current.Response.AddHeader("Location", CurrentModeCheck.Base_URL);
HttpContext.Current.ApplicationInstance.CompleteRequest();
currentMode.Request_Completed = true;
return;
}
// Browse are okay, except when it is the NEW
if ((CurrentModeCheck.Mode == Display_Mode_Enum.Aggregation) && (CurrentModeCheck.Aggregation_Type == Aggregation_Type_Enum.Browse_Info) && (!String.IsNullOrEmpty(CurrentModeCheck.Info_Browse_Mode)) && (CurrentModeCheck.Info_Browse_Mode == "new"))
{
CurrentModeCheck.Info_Browse_Mode = "all";
HttpContext.Current.Response.Status = "301 Moved Permanently";
HttpContext.Current.Response.AddHeader("Location", UrlWriterHelper.Redirect_URL(CurrentModeCheck));
HttpContext.Current.ApplicationInstance.CompleteRequest();
currentMode.Request_Completed = true;
return;
}
// Going to the search page is okay, except for ADVANCED searches ( results aren't okay, but going to the search page is okay )
if ((CurrentModeCheck.Mode == Display_Mode_Enum.Search) && (CurrentModeCheck.Search_Type == Search_Type_Enum.Advanced))
{
CurrentModeCheck.Mode = Display_Mode_Enum.Aggregation;
CurrentModeCheck.Aggregation_Type = Aggregation_Type_Enum.Home;
HttpContext.Current.Response.Status = "301 Moved Permanently";
HttpContext.Current.Response.AddHeader("Location", UrlWriterHelper.Redirect_URL(CurrentModeCheck));
HttpContext.Current.ApplicationInstance.CompleteRequest();
currentMode.Request_Completed = true;
return;
}
// If this was a legacy type request, forward to the new URL
if ((QueryString["b"] != null) || (QueryString["m"] != null) || (QueryString["g"] != null) || (QueryString["c"] != null) || (QueryString["s"] != null) || (QueryString["a"] != null))
{
HttpContext.Current.Response.Status = "301 Moved Permanently";
HttpContext.Current.Response.AddHeader("Location", UrlWriterHelper.Redirect_URL(CurrentModeCheck));
HttpContext.Current.ApplicationInstance.CompleteRequest();
currentMode.Request_Completed = true;
return;
}
// Get the depth of the url relative
// Try to determine if this is a legacy type URL and how deep the urlrelative is
int url_relative_depth = 0;
string[] url_relative_info = null;
if (QueryString["urlrelative"] != null)
{
string urlrewrite = QueryString["urlrelative"].ToLower();
if (urlrewrite.Length > 0)
{
// Split the url relative list
url_relative_info = urlrewrite.Split("/".ToCharArray());
url_relative_depth = url_relative_info.Length;
}
}
// For STATISTICS, handle some specific cases and enforce appropriate URLs
if (CurrentModeCheck.Mode == Display_Mode_Enum.Statistics)
{
// Some submodes are off limites
if ((CurrentModeCheck.Statistics_Type != Statistics_Type_Enum.Item_Count_Growth_View) && (CurrentModeCheck.Statistics_Type != Statistics_Type_Enum.Item_Count_Standard_View) && (CurrentModeCheck.Statistics_Type != Statistics_Type_Enum.Item_Count_Text) && (CurrentModeCheck.Statistics_Type != Statistics_Type_Enum.Usage_Definitions) && (CurrentModeCheck.Statistics_Type != Statistics_Type_Enum.Usage_Overall))
{
CurrentModeCheck.Statistics_Type = Statistics_Type_Enum.Usage_Overall;
HttpContext.Current.Response.Status = "301 Moved Permanently";
HttpContext.Current.Response.AddHeader("Location", UrlWriterHelper.Redirect_URL(CurrentModeCheck));
HttpContext.Current.ApplicationInstance.CompleteRequest();
currentMode.Request_Completed = true;
return;
}
// Ensure the URL behaved correctly
switch (CurrentModeCheck.Statistics_Type)
{
case Statistics_Type_Enum.Item_Count_Text:
case Statistics_Type_Enum.Item_Count_Growth_View:
case Statistics_Type_Enum.Usage_Definitions:
if (url_relative_depth > 3)
{
HttpContext.Current.Response.Status = "301 Moved Permanently";
HttpContext.Current.Response.AddHeader("Location", UrlWriterHelper.Redirect_URL(CurrentModeCheck));
HttpContext.Current.ApplicationInstance.CompleteRequest();
currentMode.Request_Completed = true;
return;
}
break;
case Statistics_Type_Enum.Usage_Overall:
if (url_relative_depth > 2)
{
HttpContext.Current.Response.Status = "301 Moved Permanently";
HttpContext.Current.Response.AddHeader("Location", UrlWriterHelper.Redirect_URL(CurrentModeCheck));
HttpContext.Current.ApplicationInstance.CompleteRequest();
currentMode.Request_Completed = true;
return;
}
break;
case Statistics_Type_Enum.Item_Count_Standard_View:
if (url_relative_depth > 2)
{
HttpContext.Current.Response.Status = "301 Moved Permanently";
HttpContext.Current.Response.AddHeader("Location", UrlWriterHelper.Redirect_URL(CurrentModeCheck));
HttpContext.Current.ApplicationInstance.CompleteRequest();
currentMode.Request_Completed = true;
return;
}
else if (url_relative_depth == 2)
{
if (( url_relative_info != null ) && (url_relative_info.Length > 1 ) && ( url_relative_info[1] != "itemcount"))
{
HttpContext.Current.Response.Status = "301 Moved Permanently";
HttpContext.Current.Response.AddHeader("Location", UrlWriterHelper.Redirect_URL(CurrentModeCheck));
HttpContext.Current.ApplicationInstance.CompleteRequest();
currentMode.Request_Completed = true;
return;
}
}
break;
}
}
// For AGGREGATION HOME handle some cases
if ((CurrentModeCheck.Mode == Display_Mode_Enum.Aggregation) && ((currentMode.Aggregation_Type == Aggregation_Type_Enum.Home) || (currentMode.Aggregation_Type == Aggregation_Type_Enum.Home_Edit)))
{
// Different code depending on if this is an aggregation or not
if (( String.IsNullOrEmpty(CurrentModeCheck.Aggregation)) || (CurrentModeCheck.Aggregation == "all"))
{
switch (CurrentModeCheck.Home_Type)
{
case Home_Type_Enum.List:
if (url_relative_depth > 0)
{
HttpContext.Current.Response.Status = "301 Moved Permanently";
HttpContext.Current.Response.AddHeader("Location", UrlWriterHelper.Redirect_URL(CurrentModeCheck));
HttpContext.Current.ApplicationInstance.CompleteRequest();
currentMode.Request_Completed = true;
return;
}
break;
case Home_Type_Enum.Descriptions:
case Home_Type_Enum.Tree:
case Home_Type_Enum.Partners_List:
if (url_relative_depth > 1)
{
HttpContext.Current.Response.Status = "301 Moved Permanently";
HttpContext.Current.Response.AddHeader("Location", UrlWriterHelper.Redirect_URL(CurrentModeCheck));
HttpContext.Current.ApplicationInstance.CompleteRequest();
currentMode.Request_Completed = true;
return;
}
break;
case Home_Type_Enum.Partners_Thumbnails:
if (url_relative_depth > 2)
{
HttpContext.Current.Response.Status = "301 Moved Permanently";
HttpContext.Current.Response.AddHeader("Location", UrlWriterHelper.Redirect_URL(CurrentModeCheck));
HttpContext.Current.ApplicationInstance.CompleteRequest();
currentMode.Request_Completed = true;
return;
}
break;
case Home_Type_Enum.Personalized:
HttpContext.Current.Response.Status = "301 Moved Permanently";
HttpContext.Current.Response.AddHeader("Location", UrlWriterHelper.Redirect_URL(CurrentModeCheck));
HttpContext.Current.ApplicationInstance.CompleteRequest();
currentMode.Request_Completed = true;
return;
}
}
}
// Ensure this is requesting the item without a viewercode and without extraneous information
if (CurrentModeCheck.Mode == Display_Mode_Enum.Item_Display)
{
if (( !String.IsNullOrEmpty(CurrentModeCheck.ViewerCode)) || (url_relative_depth > 2))
{
CurrentModeCheck.ViewerCode = String.Empty;
HttpContext.Current.Response.Status = "301 Moved Permanently";
HttpContext.Current.Response.AddHeader("Location", UrlWriterHelper.Redirect_URL(CurrentModeCheck));
HttpContext.Current.ApplicationInstance.CompleteRequest();
currentMode.Request_Completed = true;
return;
}
}
}