Telerik Forums
Community Forums Forum
3 answers
161 views
As much as we all love Telerik controls, we also dread the fact that a 50kB page using textboxes and dropdown lists can easily become over 500kB once you convert some of those into radInput boxes and radComboboxes and this is a very hard thing for some users who don't have broadband.  I'm working on a data-input page that is beginning to reach 1MB in size (just HTML) under some scenarios and we finally spent a few hours to do something about it.

With .NET 2.0 we are given System.IO.Compression that allows us to easily implement HTTPCompression on a per-application basis and if we want to get creative with our C#, we can customize it even more!

If you take a look here you will see a tutorial on how you can get this up and working.  Once you implement this, it works great, almost...

Once you follow all of their instructions and run a few tests you will find that your pages are now using HTTPCompression saving you mucho bandwidth as well as making large downloads much faster for your users!  HOWEVER, you will also notice that images begin to break and occassionally IE will crash!  All is not well!

As I'm sure many of you know, IE (and I believe some versions of Mozilla-based browsers though I could be wrong) have a/some bug(s) in them that causes them to not properly handle images and other things (PDFs don't get properly passed to Adobe, etc.) when they are compressed with HTTPCompression.

I've taken the above-linked demo and modified the logic to allow you to control what does and does not get compressed.  I basically take the URI being requested and do a search for ".htm" or ".aspx" and if I find it, I compress the response, otherwise I leave it alone.  This is not a fool-proof system as it would compress foo.htm.jpg even though it's an image and it would not (at least I don't think it would) compress "http://www.domain.com/" as the actual URI being requested doesn't specify the actual page so these two things should be kept in mind as "loopholes" in my system but it's good enough for me.  :)


Here's the code:



using System;

using System.Collections.Generic;

using System.IO;

using System.IO.Compression;

using System.Text;

using System.Web;

namespace MSDN.Demo.Whidbey.Compression

{

    public class HttpCompressionModule : IHttpModule

    {

        public HttpCompressionModule()

        {

        }

        void IHttpModule.Dispose()

        {

        }

        void IHttpModule.Init(HttpApplication context)

        {

            context.BeginRequest += new EventHandler(context_BeginRequest);

        }

        void context_BeginRequest(object sender, EventArgs e)

        {

            //

            // Get the application object to gain access to the request's details

            //

            HttpApplication app = (HttpApplication)sender;

            //

            // Accepted encodings

            //

            string encodings = app.Request.Headers.Get("Accept-Encoding");

            //

            // No encodings; stop the HTTP Module processing

            //

            if (encodings == null)

                return;

                  if (ShouldCompress(app.Request.Url.ToString()))

                  {

                        //

                        // Current response stream

                        //

                        Stream baseStream = app.Response.Filter;

                        //

                        // Find out the requested encoding

                        //

                        encodings = encodings.ToLower();

                        if (encodings.Contains( "gzip" ))

                        {

                              app.Response.Filter = new GZipStream( baseStream, CompressionMode.Compress );

                              app.Response.AppendHeader( "Content-Encoding", "gzip" );

#if DEBUG

                              app.Context.Trace.Warn( "GZIP compression on" );

#endif

                        }

                        else if (encodings.Contains( "deflate" ))

                        {

                              app.Response.Filter = new DeflateStream( baseStream, CompressionMode.Compress );

                              app.Response.AppendHeader( "Content-Encoding", "deflate" );

#if DEBUG

                              app.Context.Trace.Warn( "Deflate compression on" );

#endif

                        }

                  }

        }

            private bool ShouldCompress( string s )

            {

                  string str = s.ToLower();

                  if ((str.Contains( ".aspx" )) || (str.Contains( ".htm" )))

                  {

                        return true;

                  }

                  else

                  {

                        return false;

                  }

            }

    }

}



Enjoy!
Josef Rogovsky
Top achievements
Rank 2
 answered on 16 Dec 2005
2 answers
80 views
Hello

Is it possible (or will it become possible ;-) to view new posts since the last time you visited the forum.

Thanks

Marco
Marco Dissel
Top achievements
Rank 1
 answered on 05 Dec 2005
1 answer
92 views

Hello

Here is misc question:
In VS 2003 I used defined events in InitializeComponent

NewsList.ascx
private void InitializeComponent()
{   
   //event for usercontrol
   this.PreRender +=new EventHandler(NewsList_PreRender);
   //event for telerik control
   RadToolbar1.OnClick += new Telerik.WebControls.RadToolbar.OnClickDelegate(RadToolbar1_OnClick);
}

How (where) do I define those two event handlers in VS 2005 in partial class (I always use partial class)?

I would like a practical example of the above code! Thank you for help!

Lp
Sebastijan

Vladimir Milev
Telerik team
 answered on 05 Dec 2005
1 answer
134 views
Hello telerik,

When I want to download my r.a.d.control suite (about 128mb), it is very slow! At the same machine I can get download speeds of e.g. 2500KB/Sec.

Is there something wrong with my connection or with the upload capacity of your servers? I used to get normal download speeds at telerik, but for a month or two, it is very slow...

Hope there is an explanation for this?

Thanks!
Daniel
Boyko
Telerik team
 answered on 30 Nov 2005
1 answer
124 views
I know this isn't a telerik caused problem it is an ASP.Net 2.0 issue so figure I'd ask it here since it involves a telerik control.  I am having a problem that is probably easy but has me stumped. I am using ASP.Net 2.0 and have a master page with a menu system and then pages inherit from it. But I have a page I would like to put javascript on to use the spellcheck on more than one element, which works fine in ASP.Net 1.1.

I know on buttons I can add the attribute OnClientClick="return confirm('Are you sure')" but the script for multiple element spell checking is much more complex. If I put in a webcontrol everytime it runs it fails with an error saying my <head> tag needs the runat="server" attribute which the masterpage does have and I can't put it in a page that uses the master or the webcontrol since the head tag isn't allowed in either one...

The problem seems to be how do you do client side javacript when you are using masterpages?

Any and all suggestions are welcome...

thanks in advance

Al
Shaun Peet
Top achievements
Rank 2
 answered on 28 Nov 2005
4 answers
220 views
Hello,

Along the years our development environment has seen quite a few enhanced, specially since the arrival of .NET web development. The VS editor, syntax highlighting, auto complete, debugging, etc.. are all tools that help us write better solutions, quicker. What I am still missing is a set of tools to edit, manage, debug these little javascript code fragment. As all your controls generate quite a few javascripts, I was wondering what tools you use internally while elaborating these scripts ? Some recommendations ?

Cheers
Roger
armand datema
Top achievements
Rank 2
 answered on 09 Nov 2005
3 answers
113 views
its there any plans to have a 'skins' area where people can show their designs or list sites they have used telerik components with?
Vassil Petev
Telerik team
 answered on 27 Oct 2005
0 answers
81 views
VS 2005 has just been released for download by MSDN Subscribers accordning to the new Subscription System. Even the RTM version of SQL 2005 Server Developer Edition is ready to download. Final build number is 8.0.50727.42 for Visual Studio and 2.0.50727.42 for the .Net Framework.

Enjoy!
adec
Top achievements
Rank 1
 asked on 27 Oct 2005
3 answers
141 views
Hi,

Not really important, but I thought it was worth mentioning. Every time when Telerik releases hotfixes or a service pack, you update the RSS feed to notify people that new stuff is out. This is great, although I'm not sure it works properly, however the problem could be on my side. I'm using FeedReader (www.feedreader.com) to check new RSS feeds and experience that when you update the RSS feeds, all (or a lot) of earlier news messages also get marked as new (probably all got the same date as the new ones). I hope you understand what I mean, as in FeedReader I can't easily see what's new, and what's not.

Anyway maybe if you find time you can look into it,

Kind regards,

Martin de Ruiter
Zhivko Dimitrov
Telerik team
 answered on 28 Sep 2005
1 answer
112 views
This question is not really a telerik issue - however I think this forum might be the place to ask. 

For some reason, I have lost in my VS the telerik toolboxes.  It was so neat to just click and drag and everything was in place. 

Where do I look for in the VS Toolbox, add/remove items, 'Customize Toolbox'  browse  - to find the Telerik Controls - so that it would be as easy as I once had it?

Thanks
Karl
Karl
Top achievements
Rank 1
 answered on 20 Sep 2005
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?