Krav: En ny IHttpModule-modul har lagts till för att blockera alla HTTP-förfrågningar och räkna tiden det tar från början till slut av förfrågningar, vilket gör det enklare att felsöka tidskrävande sidor samt optimera och förbättra användarupplevelsen.
I ASP.NET är många redan förutbestämdaHttpModule, och till och med redan registrerad i serverns webbplatsprofil, i systemmappenC:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\web.configSe den registrerade HttpModule enligt följande:
<httpModules> <lägg till namn="OutputCache" typ="System.Web.Caching.OutputCacheModule"/> <lägg till namn="Session" typ="System.Web.SessionState.SessionStateModule"/> <lägg till namn="WindowsAuthentication" typ="System.Web.Security.WindowsAuthenticationModule"/> <lägg till namn="FormsAuthentication" type="System.Web.Security.FormsAuthenticationModule"/> <lägg till namn="PassAutentisering" typ="System.Web.Security.PassportAuthenticationModule"/> <lägg till namn="RoleManager" typ="System.Web.Security.RoleManagerModule"/> <lägg till namn="UrlAuthorization" typ="System.Web.Security.UrlAuthorizationModule"/> <lägg till namn="Filauktorisation" typ="System.Web.Security.FileAuthorizationModule"/> <lägg till namn="AnonymIdentifiering" typ="System.Web.Security.AnonymousIdentificationModule"/> <lägg till namn="Profil" typ="System.Web.Profile.ProfileModule"/> <lägg till namn="ErrorHandlerModule" typ="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"/> <lägg till namn="UrlRoutingModule-4.0" typ="System.Web.Routing.UrlRoutingModule"/> <lägg till namn="ScriptModule-4.0" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> </httpModules> Skapa ett nytt RequestTimeHttpModule-objekt som ärver IHttpModule-gränssnittet, och koden är följande:
Vår nya HttpModule-modul måste också konfigureras i web.config, enligt följande:
Försök komma åt webbplatsen, renderingen är följande:
ASP.NET HTTP-moduler och HTTP-hanterare:Inloggningen med hyperlänken är synlig.
(Slut)
|