[CLOSED] WebResource.axd resources are not gzipped. Is it possible to make Ext.NET's Resource Handler public?

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] WebResource.axd resources are not gzipped. Is it possible to make Ext.NET's Resource Handler public?

    Hi,

    In the Ext.NET book (p.321) I talk about using embedded resources for custom components, plus some scenarios where you might want to do this (as it is not mandatory) for example, to ship a component fully encapsulated, or to save the hassle of remembering to include the right resources in each page that might use the custom component (if you don't want to include it once in a master template or similar).

    I've regrettably overlooked that these embedded resources, although they would use the ASP.NET web resource, will not get gzipped (seems a limitation to me; not sure why they don't support it - by comparison, ScriptResource.axd, does support gzip). Some module/handler-based solutions exist, but they seem to have side-effects from my quick look.

    I guess the options, therefore, are
    • Stick with Embedded Resources and WebResource.axd (and manage any gzip/minification versions manually/yourself)
    • Try to create your own handler (can be tricky to get right to factor in gzipping, client caching support, minification, and so on)
    • Use Bundles from ASP.NET or similar custom bundling solutions that support gzip (and minification as a bonus)
    • Use Ext.Net.ResourceHandler (if it was public)? (As well as gzipping, this also supports minification as a bonus)


    For my main project where I use Ext.NET I am seriously thinking of abandoning the Embedded Resource approach (in about 90% of the cases I think) in favour of migrating towards Bundles, as that will also automatically minify as well as compress and can be used with WebForms and MVC.

    But would it be possible to make your resource handler public so it is usable by others? Looking at the code briefly it looks like there are some things specific to Ext.NET so it may not be easy to do that without some refactoring?

    Or have I missed other options?

    Thanks!
    Last edited by Daniil; Nov 27, 2013 at 7:04 AM. Reason: [CLOSED]
  2. #2
    Hi Anup,

    This is related to functionality I've wanted to refactor and expand upon for some time. I will discuss with the team and see if we can improve upon the resource handling options for the 2.4 release (expected early December).
    Geoffrey McGill
    Founder
  3. #3
    Now you say that, I seem to remember a discussion where you mentioned that :)

    Look forward to hearing about it.
  4. #4
    Hm... I think I found another place where I missed an opportunity to compress data, thinking IIS would do it for you, and it was a missed opportunity for the book, too.

    It is in ashx, for example, when returning some raw JSON data, e.g. as part of a store paging ajax request. I often use (and gave examples of in the book) something like this:

    context.Response.Write(JSON.Serialize(myObject));
    I have assumed, without checking, that IIS will compress this because it has these kinds of settings in web.config:

    <urlCompression doStaticCompression="true" doDynamicCompression="true" />
    Since IIS 7.5 these are both defaulted to true, so not explicitly needed in web.config any more. But regardless, you would think all appropriate responses will get compressed. But as we have seen with WebResource.axd it doesn't. And that seems to be the case with ASHX (if using the above type of code). I am not sure why this is different as I would have thought IIS normally has a good layered architecture for this kind of stuff (it may be related to the way generic handlers take part in the processing pipeline and where that sits in IIS's pipeline, perhaps). Bit frustrating for this otherwise very nice and simple configuration. By comparison, in Apache, turning on compression is far more consistently applied!

    But luckily your very useful method comes to the rescue here:

    CompressionUtils.GZipAndSend(JSON.Serialize(myObject));
    I'll look into this further, and maybe I'll post an update for my book on my blog if needed.

    (Don't think this will really affect you on the Ext.NET side as this is more of a general issue with ASP.NET/IIS I guess, so it is a bit of an aside...!)
  5. #5
    Quote Originally Posted by anup View Post
    (Don't think this will really affect you on the Ext.NET side as this is more of a general issue with ASP.NET/IIS I guess, so it is a bit of an aside...!)
    I guess one area that could help is in the Examples Explorer. Where you have examples such as this:

            public void ProcessRequest(HttpContext context)
            {
                context.Response.ContentType = "application/json";
    
                StoreRequestParameters prms = new StoreRequestParameters(context);
                Paging<Plant> plants = Plant.PlantsPaging(prms.Start, prms.Limit, prms.Sort[0].Property, prms.Sort[0].Direction.ToString(), string.Empty);
    
                context.Response.Write(JSON.Serialize(plants));
            }
    You could replace it with this?

            public void ProcessRequest(HttpContext context)
            {
                StoreRequestParameters prms = new StoreRequestParameters(context);
                Paging<Plant> plants = Plant.PlantsPaging(prms.Start, prms.Limit, prms.Sort[0].Property, prms.Sort[0].Direction.ToString(), string.Empty);
    
                CompressionUtils.GZipAndSend(JSON.Serialize(plants));
            }
    This would apply to both Ext.NET 1.x and 2.x

    Hope that helps.
  6. #6
    Anup, I ended up building my own handlers and compression tools (as well as minifiers) because of some of the concerns you raised. It was painful but I think I worked-through most of the scenarios. I'm even able to minify the embedded script generated by extnet or statically in my own code through use of Adapters. I technically have enough code to release a library. Maybe someday.
    Last edited by michaeld; Nov 14, 2013 at 11:16 AM.
  7. #7
    Hi

    Now ResourceHandler supports web resources from non Ext.Net assembly, if a widget is inherited from Ext.Net control and placed in another assembly then its web resources (described in Resources property) will be extracted via Ext.Net ResourceHandler (with compression and caching)
  8. #8
    Vladimir, apologies for my delayed response. Just got latest and tried it out. Fantastic stuff! Many thanks. You can mark this as closed.
  9. #9
    Kudos on this...

    Would this also work to register other additional external resource files from our own projects like you can do with ScriptManager?
  10. #10
    Quote Originally Posted by michaeld View Post
    Kudos on this...

    Would this also work to register other additional external resource files from our own projects like you can do with ScriptManager?
    From the looks of it, it will work for your custom components where you override the resource property and point to other embedded resources.

    But, if you have things like site-wide JS/CSS files you want to include, another options is using Bundles? It is quite powerful.

    Hope that helps.
Page 1 of 2 12 LastLast

Similar Threads

  1. [OPEN] [#356] Gzipped extnet static resources not persistanced
    By michaeld in forum 2.x Legacy Premium Help
    Replies: 11
    Last Post: Oct 15, 2013, 11:55 AM
  2. Replies: 5
    Last Post: Jun 20, 2012, 8:50 AM
  3. Replies: 1
    Last Post: Sep 20, 2011, 6:02 AM
  4. [CLOSED] Make Ext.Net.ResourceManager.IsClientStyleIncludeRegist ered public
    By SouthDeveloper in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Apr 18, 2011, 1:30 AM
  5. [CLOSED] Make AdditionalConfig public
    By randy85253 in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Oct 13, 2009, 11:00 AM

Posting Permissions