Prasības: Ir pievienots jauns IHttpModule modulis, lai bloķētu visus HTTP pieprasījumus un skaitītu laiku, kas nepieciešams no pieprasījumu sākuma līdz beigām, atvieglojot laikietilpīgu lapu problēmu novēršanu un optimizēt un uzlabot lietotāja pieredzi.
ASP.NET daudzi jau ir iepriekš definētiHttpModuleun pat jau reģistrēts servera tīmekļa vietnes profilā, sistēmas mapēC:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\web.configSkatiet reģistrēto HttpModule šādi:
<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> Izveidojiet jaunu RequestTimeHttpModule objektu, kas pārmanto IHttpModule interfeisu, un kods ir šāds:
Mūsu jaunais HttpModule modulis ir jākonfigurē arī web.config šādi:
Mēģiniet piekļūt vietnei, renderēšana ir šāda:
ASP.NET HTTP moduļi un HTTP apdarinātāji:Hipersaites pieteikšanās ir redzama.
(Beigas)
|