要件:すべてのHTTPリクエストをブロックし、リクエストの開始から終了までの時間をカウントする新しいIHttpModuleモジュールが追加され、時間のかかるページのトラブルシューティングやユーザー体験の最適化・改善が容易になりました。
ASP.NET では、多くはすでにあらかじめ定義されていますHttpModuleさらにはサーバーのウェブサイトプロファイルやシステムフォルダにもすでに登録されていますC:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\web.config登録されたHttpモジュールは以下の通りです:
<httpModules> <add name="OutputCache" type="System.Web.Caching.OutputCacheModule"/> <add name="Session" type="System.Web.SessionState.SessionStateModule"/> <add name="WindowsAuthentication" type="System.Web.Security.WindowsAuthenticationModule"/> <add name="FormsAuthentication" type="System.Web.Security.FormsAuthenticationModule"/> <add name="PassportAuthentication" type="System.Web.Security.PassportAuthenticationModule"/> <add name="RoleManager" type="System.Web.Security.RoleManagerModule"/> <add name="UrlAuthorization" type="System.Web.Security.UrlAuthorizationModule"/> <add name="FileAuthorization" type="System.Web.Security.FileAuthorizationModule"/> <add name="AnonymousIdentification" type="System.Web.Security.AnonymousIdentificationModule"/> <add name="Profile" type="System.Web.Profile.ProfileModule"/> <add name="ErrorHandlerModule" type="System.Web.Mobile.ErrorHandlerModule, System.Web.Mobile, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/> <add name="ServiceModel" type="System.ServiceModel.Activation.HttpModule, System.ServiceModel.Activation, Version=4.0.0.0, culture=neutral, PublicKeyToken=31bf3856ad364e35"/> <add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule"/> <add name="ScriptModule-4.0" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> </httpModules> IHttpModuleインターフェースを継承する新しいRequestTimeHttpModuleオブジェクトを作成し、コードは以下の通りです。
新しいHttpModuleモジュールもweb.configで以下のように設定する必要があります:
ウェブサイトにアクセスしてみてください。レンダリングは以下の通りです:
ASP.NET HTTPモジュールとHTTPハンドラ:ハイパーリンクのログインが見えます。
(終わり)
|