私は Stackoverflow から次のコードを拾いました->Sitecore でカスタム 404 を処理しているブログ (実際には、Google によってソフト 404 としてピックアップされるステータス 200 で 302 リダイレクトを 404 ページに行います)。
これはローカルのテストサーバーではまったく問題なく動作しますが、本番環境にドロップすると、サイトが混乱し、ロードなどに 8 ~ 9 分かかるなど、AGES がかかります。
public class ExecuteRequest : Sitecore.Pipelines.HttpRequest.ExecuteRequest
{
protected override void RedirectOnItemNotFound(string url)
{
var context = System.Web.HttpContext.Current;
try
{
// Request the NotFound page
var domain = context.Request.Url.GetComponents(
UriComponents.Scheme | UriComponents.Host,
UriFormat.Unescaped);
var content = WebUtil.ExecuteWebPage(
string.Concat(domain, url));
// The line below is required for IIS 7.5 hosted
// sites or else IIS is gonna display default 404 page
context.Response.TrySkipIisCustomErrors = true;
context.Response.StatusCode = 404;
context.Response.Write(content);
}
catch (Exception ex)
{
Log.Error(string.Format("Falling back to default redirection behavior. Reason for error {0}", ex), ex);
// Fall back to default behavior on exceptions
base.RedirectOnItemNotFound(url);
}
context.Response.End();
}
}
PS: 次に、ExecuteRequest を web.config 内のカスタムのものに置き換えました。
同様のことを経験したことがある場合、またはこれに関する問題を知っている場合は、いくつかの光を当ててください.
前もって感謝します