web.configの[モジュール]セクションの[カスタムエラーハンドラ]を追加します(手動ではありません)。

sharepoint.stackexchange https://sharepoint.stackexchange.com//questions/37736

質問

手動で行わずにweb.configのモジュールセクションの先頭にエラーハンドラhttpModuleを配置する方法はありますか?

このような補足web.configアプローチを試しました:

  <add path="configuration/system.webServer/modules" id="{125A654F-9220-42F0-A97A-1746252468DE}">
    <add name="CustomErrorHandler" type="com.handlers.CustomErrorHandler, Assemblyname, Version=4.5.6.7, Culture=neutral, PublicKeyToken=3450345789" />
  </add>
.

問題は、カスタムエラーハンドラを標準ハンドラの前に配置する必要があることです。そうでない場合、SharePointは例外自体を処理し、標準例外ページを配信します。

予想:

 <modules runAllManagedModulesForAllRequests="true">
  <add name="CustomErrorHandler" type="com.handlers.CustomErrorHandler, Assemblyname, Version=4.5.6.7, Culture=neutral, PublicKeyToken=3450345789" />
  <remove name="FileAuthorization" />
  <remove name="Profile" />
  <remove name="WebDAVModule" />
  <remove name="Session" />
  <add name="SPRequestModule" preCondition="integratedMode" type="Microsoft.SharePoint.ApplicationRuntime.SPRequestModule, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
  <add name="ScriptModule" preCondition="integratedMode" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
  <add name="SharePoint14Module" preCondition="integratedMode" />
  <add name="StateServiceModule" type="Microsoft.Office.Server.Administration.StateModule, Microsoft.Office.Server, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
  <add name="RSRedirectModule" type="Microsoft.ReportingServices.SharePoint.Soap.RSRedirectModule, RSSharePointSoapProxy, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />
  <add name="PublishingHttpModule" type="Microsoft.SharePoint.Publishing.PublishingHttpModule, Microsoft.SharePoint.Publishing, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
</modules>
.

補助的アプローチによる結果:

<modules runAllManagedModulesForAllRequests="true">
  <remove name="FileAuthorization" />
  <remove name="Profile" />
  <remove name="WebDAVModule" />
  <remove name="Session" />
  <add name="SPRequestModule" preCondition="integratedMode" type="Microsoft.SharePoint.ApplicationRuntime.SPRequestModule, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
  <add name="ScriptModule" preCondition="integratedMode" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
  <add name="SharePoint14Module" preCondition="integratedMode" />
  <add name="StateServiceModule" type="Microsoft.Office.Server.Administration.StateModule, Microsoft.Office.Server, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
  <add name="RSRedirectModule" type="Microsoft.ReportingServices.SharePoint.Soap.RSRedirectModule, RSSharePointSoapProxy, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />
  <add name="PublishingHttpModule" type="Microsoft.SharePoint.Publishing.PublishingHttpModule, Microsoft.SharePoint.Publishing, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
  <add name="CustomErrorHandler" type="com.handlers.CustomErrorHandler, Assemblyname, Version=4.5.6.7, Culture=neutral, PublicKeyToken=3450345789" />
</modules>
.

このスレッドが言うように(MS開発者別)SPWebConfigModificationの操作時のノードの順序を制御する方法はありません。

http:/ /social.technet.microsoft.com/forums/en-us/SharePoint2010Programming/Thread/154A09DE-D9FC-4622-A397-589A3C1A87E5 /

web.configエントリの追加手動ではオプションなしです。

は他に違いない方法はありませんか?

役に立ちましたか?

解決 2

最後に私はカスタムエラーページのための異なるアプローチで終わりました。

プログラムでプログラム(そんなに多くを吸う!)の要素の順序を制御できないため、手動で編集はオプションではありません。httpModuleを使用してweb.configを操作します。

ここで説明したWebアプリケーションスコープ機能受信者を書きました。 http://todd-carter.com /post/2010/04/07/0an-expected-error-has-occurred.aspx アプリケーション(例外を処理する)のカスタムエラーページを設定します。カスタムエラーページには、ユーザーのカスタムメッセージをレンダリングして例外を記録するコントロールがあります。

さらに、マップされたレイアウト\ 1033フォルダ内のカスタム404.htmlファイルをソリューションに追加し、そのファイルを同じ機能受信機に登録しました(下記のコードを参照)。 404.htmlは.aspx-fileにリダイレクトします。 ASPXには、内容が国際化されたコントロールがあります。静的HTMLを404のエラーに設定するだけです。リダイレクトの理由は国際化でした。

.htmlファイルと非IEブラウザを持つ1つの追加の落とし穴は、ここで説明されている問題(標準のSP 404.htmlを出発点にコピーしたため)の問題でした。

http://andreasglaser.net/post/2009/03/15/sharepoint-and-custom-404-page-not-found-and-8-issue-with-firefox。 ASPX

コードはここに行きます:

private const string CustomErrorPage = "/_layouts/CustomError.aspx";

public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
  SPWebApplication webApp = properties.Feature.Parent as SPWebApplication;

  if (webApp != null)
  {
    if (!webApp.UpdateMappedPage(SPWebApplication.SPCustomPage.Error, CustomErrorPage))
    {
      throw new ApplicationException("Cannot create the new error page mapping.");
    }
  }

  webApp.FileNotFoundPage = "Custom404.html";
  webApp.Update(true);
}

public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
{
  SPWebApplication webApp = properties.Feature.Parent as SPWebApplication;

  if (!webApp.UpdateMappedPage(SPWebApplication.SPCustomPage.Error, null))
  {
    throw new ApplicationException("Cannot reset the default error page mapping.");
  }
  webApp.FileNotFoundPage = String.Empty;
  webApp.Update(true);
}
.

他のヒント

予想どおりに機能しない場合は、 XPathを使用することをお勧めします。順序を定義するためにSPWebモジファイションと共に。

更新

私はXPathソリューションと一緒に私の解決策をテストし、それは期待通りに動作しません。エントリーの順序を制御するなしの方法があるようです。彼の入力に感謝します!

アップデート2

HttpApplicationの代わりにHttpContextを使用してみてください.HttpApplicationは、ASP.NETアプリケーション内のすべてのアプリケーションオブジェクトに共通のメソッド、プロパティ、およびイベントを定義しています。もっと見る

使用

 HttpContext context = ((HttpApplication)sender).Context;
.

ライセンス: CC-BY-SA帰属
所属していません sharepoint.stackexchange
scroll top