Application_Error メソッドを Global.asax ファイルに追加しようとしていますが、パーサー エラーが発生します。
「/」アプリケーションでサーバー エラーが発生しました。パーサー エラーの説明: この要求を処理するために必要なリソースの解析中にエラーが発生しました。次の特定の解析エラーの詳細を確認し、ソース ファイルを適切に変更してください。
パーサー エラー メッセージ: アプリケーション ファイルの内容が無効です。
この方法が機能しない理由がわかりません。どんな助けでも感謝します!
<%@Application Language='C#' Inherits="Sitecore.Web.Application" %>
using System.Configuration;
protection void Application_Error(object sender, EventArgs e)
{
// Code that runs when an unhandled error occurs
// Get the exception object.
Exception exc = Server.GetLastError();
// Handle HTTP errors
if (exc.GetType() == typeof(HttpException))
{
// The Complete Error Handling Example generates
// some errors using URLs with "NoCatch" in them;
// ignore these here to simulate what would happen
// if a global.asax handler were not implemented.
if (exc.Message.Contains("NoCatch") || exc.Message.Contains("maxUrlLength"))
return;
//Redirect HTTP errors to HttpError page
Server.Transfer("HttpErrorPage.aspx");
}
// For other kinds of errors give the user some information
// but stay on the default page
Response.Write("<h2>Global Page Error</h2>\n");
Response.Write(
"<p>" + exc.Message + "</p>\n");
Response.Write("Return to the <a href='Default.aspx'>" +
"Default Page</a>\n");
// Log the exception and notify system operators
ExceptionUtility.LogException(exc, "DefaultPage");
ExceptionUtility.NotifySystemOps(exc);
// Clear the error from the server
Server.ClearError();
}