• Code
  • Tags
  • Users
  • Titles
  • Log in
  • Feedback
  • FAQ
Share Code
Welcome to ForkCan.com

ForkCan is all about sharing code in a social way.

Discuss, debate or argue with other devs about their or your own code.

Give other devs feedback or make a Fork (Make a better version of a shared code).

Rate the code, if you use the code mark it as used so others can see if the shared code is used by someone.

Help each other to be better devs and to be more productive.


Features not working yet:

Flag a post


QR Code

Tiny Url

http://4kcan.com/s/MjEz

Related Code
Fork of GZIP your Actions in MVC if not used as standard in IIS7 or only use IIS6
PagedList class and paging code for ASP.Net MVC (Nothing new but kind of usefull.)
ActionFilter to Handle and Log Error for each Controller, ASP.NET MVC
Get Cookies in Web Api Asp .net Mvc 4 RC
Using DynamicObject to get a value from the Request.Params
Unity Service Locator for ASP.NET MVC 3.0 Beta 1
Google Analytics helper for ASP.NET Razor
Unity Controller Factory for ASP.NET MVC 3.0
Removing properties from the model state the typed way in ASP.NET MVC
A simple way to cache slow functions in C#
Fork of Serialize an object into a Querystring, using LINQ syntax
UnitOfWork Action filter for ASP.NET MVC and nHibernate
Serialize an object into a Querystring
Make sure the web.config pages/namespace can be used together with ASP.NET MVC 3 P1 and Razor
StringFormat Extension method for HtmlHelper ASP.NET MVC
HttpContextLifetimeManager for Unity
ASP.NET MVC 4.0 Web API Message logger for .Net 4.0
Extension to the HttpClient

GZIP your Actions in MVC if not used as standard in IIS7 or only use IIS6

Action FIlter for MVC to GZIP your reults if not turned on as default in IIS7 or if you use IIS6

0
877 0 0 0 0 1

public class CompressAttribute : ActionFilterAttribute
    {
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            HttpRequestBase request = filterContext.HttpContext.Request;

            string acceptEncoding = request.Headers["Accept-Encoding"];

            if (string.IsNullOrEmpty(acceptEncoding)) return;

            acceptEncoding = acceptEncoding.ToUpperInvariant();

            HttpResponseBase response = filterContext.HttpContext.Response;

            if (acceptEncoding.Contains("GZIP"))
            {
                response.AppendHeader("Content-encoding", "gzip");
                response.Filter = new GZipStream(response.Filter, CompressionMode.Compress);
            }
            else if (acceptEncoding.Contains("DEFLATE"))
            {
                response.AppendHeader("Content-encoding", "deflate");
                response.Filter = new DeflateStream(response.Filter, CompressionMode.Compress);
            }
        }
    }

Share: twitter | facebook   Action: used | fork | flag

actionfilter

Mark 'actionfilter' tag as 'like'

Mark 'actionfilter' tag as 'ignore'

asp.net

Mark 'asp.net' tag as 'like'

Mark 'asp.net' tag as 'ignore'

aspmvc

Mark 'aspmvc' tag as 'like'

Mark 'aspmvc' tag as 'ignore'

c#

Mark 'c#' tag as 'like'

Mark 'c#' tag as 'ignore'

mvc

Mark 'mvc' tag as 'like'

Mark 'mvc' tag as 'ignore'


 @johannormen "Code Contributor"
1.24k
July 20, 2010 8:33 PM

Fork

 GZIP your Actions in MVC if not used as standard in IIS7 or only use IIS6 -  @johannormen Tuesday 20, 2010 8:33 PM
 Fork of GZIP your Actions in MVC if not used as standard in IIS7 or only use IIS6 - Stefan Rusek Monday 25, 2011 12:00 PM


0 Feedback


You must log in before you can give any feedback


1 Discussion(s)

Newest Oldest
0

I forked this with an updated version:

  • The original code doesn't recognize x-gzip nor x-compress, which the RFC says should be equivalent to gzip and compress.
  • Reduced duplicate code.
link | flag  | Reply

 Stefan Rusek
115
Monday 25, 2011 12:26 PM


You must log in before you can post a comment

Squeed
Made by: Fredrik Normén 2010