Programming Microsoft ASP.NET MVC by Dino Esposito
Author:Dino Esposito
Language: eng
Format: epub, pdf
Tags: COMPUTERS / Web / Web Programming
ISBN: 9780735680937
Publisher: Microsoft Press
Published: 2014-02-17T16:00:00+00:00
Compressing the response
These days, HTTP compression is a feature that nearly every website can afford because the number of browsers that have trouble with that is approaching zero. (Any browser released in the past 10 years recognizes the most popular compression schemes.)
In ASP.NET Web Forms, compression is commonly achieved through HTTP modules that intercept any request and compress the response. You can also turn on compression at the Internet Information Services (IIS) level. Both options work well in ASP.NET MVC, so the decision is up to you. You typically make your decision based on the parameters you need to control, including the MIME type of the resource to compress, level of compression, files to compress, and so forth.
ASP.NET MVC makes it particularly easy to implement a third option: an action-specific filter that sets things up for compression. In this way, you can control a specific URL without the need to write an HTTP module. Let’s go through another example of an action filter that adds compression to the response stream for a particular method.
In general, HTTP compression is controlled by two parameters: the Accept-Encoding header sent by the browser with each request, and the Content-Encoding header sent by the web server with each response. The Accept-Encoding header indicates that the browser is able to handle only the specified encodings—typically, gzip and deflate. The Content-Encoding header indicates the compression format of the response. Note that the Accept-Encoding header is just a request header sent by the browser; in no way should the server feel obliged to return compressed content.
When it comes to writing a compression filter, the hardest part is gaining a full understanding of what the browser is requesting. Here’s some code that works:
Download
Programming Microsoft ASP.NET MVC by Dino Esposito.pdf
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Exploring Deepfakes by Bryan Lyon and Matt Tora(7589)
Robo-Advisor with Python by Aki Ranin(7479)
Offensive Shellcode from Scratch by Rishalin Pillay(6034)
Ego Is the Enemy by Ryan Holiday(4924)
Microsoft 365 and SharePoint Online Cookbook by Gaurav Mahajan Sudeep Ghatak Nate Chamberlain Scott Brewster(4882)
Management Strategies for the Cloud Revolution: How Cloud Computing Is Transforming Business and Why You Can't Afford to Be Left Behind by Charles Babcock(4431)
Python for ArcGIS Pro by Silas Toms Bill Parker(4109)
Elevating React Web Development with Gatsby by Samuel Larsen-Disney(3816)
Machine Learning at Scale with H2O by Gregory Keys | David Whiting(3533)
Learning C# by Developing Games with Unity 2021 by Harrison Ferrone(3276)
Speed Up Your Python with Rust by Maxwell Flitton(3226)
Liar's Poker by Michael Lewis(3208)
OPNsense Beginner to Professional by Julio Cesar Bueno de Camargo(3188)
Extreme DAX by Michiel Rozema & Henk Vlootman(3166)
Agile Security Operations by Hinne Hettema(3115)
Linux Command Line and Shell Scripting Techniques by Vedran Dakic and Jasmin Redzepagic(3105)
Essential Cryptography for JavaScript Developers by Alessandro Segala(3080)
Cryptography Algorithms by Massimo Bertaccini(2998)
AI-Powered Commerce by Andy Pandharikar & Frederik Bussler(2977)
