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

View: 14502|Reply: 0

[ASP.NET] Styles.Render triggers the thought of runAllManagedModulesForAllRequests=true

[Copy link]
Posted on 10/13/2016 3:02:09 PM | | |
In the previous article, there is another legacy problem that has not been solved, that is, ASP.NET MVC MapRoute .htm does not work, how to solve it if you do not use runAllManagedModulesForAllRequests="true"? Later, I found a solution:



Reference: ASP.NET MVC: Route a .html request to an MVC route

I discussed why you should try not to use runAllManagedModulesForAllRequests="true", and then I found two related articles:

The art of simplicity: Optimize the performance of your web applications: Don’t use runAllManagedModulesForAllRequests="true”.
Don't use runAllManagedModulesForAllRequests="true" when getting your MVC routing to work
Excerpt from a description in the text:

This highly recommended fix can cause other problems. These problems come in the form of making all your registered HTTP modules run on every request, not just managed requests (e.g. .aspx). This means modules will run on ever .jpg .gif .css .html .pdf etc.

runAllManagedModulesForAllRequests is like a channel switch for IIS Modules and requests, if this switch is turned on, then all requests that access this site will go into Modules for processing, which includes some static file requests, which is also the most common kind of "no need to process" requests, because the request enters Modules, then there must be a corresponding program to process it. This causes unnecessary performance overhead, because static files are just for display, there is no need to do Modules processing at all, small sites don't matter, when some large PV sites do the same, it will cause some "pressure" on IIS's Modules program processing, and the conclusion summarized in a blog post above is waste (waste... ) and potential (potential... )。

Let's do a test with Application_BeginRequest to see what requests are logged for different configurations of runAllManagedModulesForAllRequests, and test the sample code:


runAllManagedModulesForAllRequests="fasle", data.txt log:
http://localhost:55127/
http://localhost:55127/bundles/test2?v=2Fz3B0iizV2NnnamQFrx-NbYJNTFeBJ2GM05SilbtQU1
http://localhost:55127/bundles/test1?v=MDbdFKJHBa_ctS5x4He1bMV0_RjRq8jpcIAvPpKiN6U1

runAllManagedModulesForAllRequests="true", data.txt record:

http://localhost:55127/
http://localhost:55127/bundles/test2?v=2Fz3B0iizV2NnnamQFrx-NbYJNTFeBJ2GM05SilbtQU1
http://localhost:55127/bundles/test1?v=MDbdFKJHBa_ctS5x4He1bMV0_RjRq8jpcIAvPpKiN6U1
http://localhost:55127/Content/logo_small_1.gif
http://localhost:55127/Content/logo_small_4.gif
http://localhost:55127/Content/logo_small_2.gif
http://localhost:55127/Content/logo_small_3.gif

logo_small_* The image is what I added in the view, this is just a request to test a static image, if you are on a large site, add the request test code, and then refresh the page, you will find that there are a lot of meaningless requests. Maybe you look at the test record above, it doesn't seem to explain any problem, but just imagine, if a site with a lot of static files, and then the number of visits is tens of millions, and the site contains many pages, although it is a small problem, it will be infinitely magnified, and finally you find that it is just a configuration problem.

That's it, I'm going to change the code.





Previous:C# dictionary key to sort
Next:asp.net Access to static resources in MVC routes
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