I am developing an application using asp.net 2.0 (C#), in which I am trying to implement the compression of my files, so that performance of my website will improve.
For that I have added a code in my Global.asax file to compress all requests (.aspx, .js, .css) But when I am running my application it works well for first time then the CSS is not loading and web page is not rendering properly.
Why its happening??
Edited (added my compression code)
My compression code of Global.asax file is as follows:
void Application_BeginRequest()
{
HttpContext incoming = HttpContext.Current;
string oldpath = incoming.Request.Path.ToLower();
incoming.Response.Filter = new GZipStream(incoming.Response.Filter, CompressionMode.Compress);
HttpContext.Current.Response.AppendHeader("Content-encoding", "gzip");
HttpContext.Current.Response.Cache.VaryByHeaders["Accept-encoding"] = true;
}
Also please let me know if there is any other better way to do the same, using the Global.asax file, because I don't have access of IIS Settings and also I don't have permission to implement the HttpModule, that is why I am using Global.asax file.
Thanks