This article is a mirror article of machine translation, please click here to jump to the original article.

View: 3197|Reply: 2

[ASP.NET] ASP.NET MVC counts requests based on IHttpModule modules

[Copy link]
Posted on 7/14/2023 8:25:37 PM | | | |
Requirements: A new IHttpModule module has been added to block all HTTP requests and count the time it takes from start to end of requests, making it easier to troubleshoot time-consuming pages and optimize and improve user experience.

asp.net IHttpModule interface is explained in detail
https://www.itsvse.com/thread-4580-1-1.html

Asp.Net IHttpHandler introduced
https://www.itsvse.com/thread-4579-1-1.html

Use the general handler (IHttpHandler) to make a global watermark of the image
https://www.itsvse.com/thread-2277-1-1.html

In ASP.NET, many are already predefinedHttpModule, and even already registered in the server's website profile, in the system folderC:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\web.configSee the registered HttpModule as follows:

<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>

Create a new RequestTimeHttpModule object that inherits the IHttpModule interface, and the code is as follows:

Our new HttpModule module also needs to be configured in web.config, as follows:

Try to access the website, the rendering is as follows:



ASP.NET HTTP modules and HTTP handlers:The hyperlink login is visible.

(End)




Previous:Redis memory eight elimination strategies
Next:.NET/C# NamedPipe-based NamedPipe Cross-Process Communication [with Source Code]
Posted on 7/28/2023 2:49:01 PM |
Is there a case for net core?
 Landlord| Posted on 7/28/2023 10:47:13 PM |
920986096 Posted on 2023-7-28 14:49
Is there a case for net core?
asp.net core writes a middleware to record the interface time
https://www.itsvse.com/thread-8079-1-1.html


I'll write it again later
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com