ResourceManager's RenderScripts = File throws 'Ext' is undefined

Page 2 of 3 FirstFirst 123 LastLast
  1. #11
    Whether I use IISExpress, or IIS (I normally use IIS only) I see the same odd behaviour across all project combinations I mentioned earlier... Very strange :)

    WebResource.axd also provides gzip and caching from what I can see in the http headers (sends gzipped + last modified and related headers to help with caching).

    If time allows, maybe on the weekend I will try again with latest code and a brand new project.
  2. #12
    WebResource.axd also provides gzip and caching from what I can see in the http headers (sends gzipped + last modified and related headers to help with caching).
    Maybe, our resource handler appeared before the time when WebResource.axd started to cache and gzip resources by default.

    For example, there is a question how to enable those features for WebResource.axd.
  3. #13
    Yes. fair point.

    I've just got latest code from SVN and rebuilt. I've updated my web.config to comment out the modules/handlers for system.web.

    While it all works, the resources loaded are webresource.axd not the cleaner ext.axd, regardless of whether I use cleanResourceUrl="true" or not:

    Am I missing anything here (it should be barebones, other than what is needed for ASP.NET MVC, Web Forms, Web API and Ext.NET

    <?xml version="1.0" encoding="utf-8"?>
            <section name="extnet" type="Ext.Net.GlobalConfig" requirePermission="false" />
            <add key="webpages:Version" value="" />
            <add key="webpages:Enabled" value="false" />
            <add key="PreserveLoginUrl" value="true" />
            <add key="ClientValidationEnabled" value="true" />
            <add key="UnobtrusiveJavaScriptEnabled" value="true" />
            <compilation debug="true" targetFramework="4.5" />
            <httpRuntime targetFramework="4.5" />
                    <add namespace="System.Web.Helpers" />
                    <add namespace="System.Web.Mvc" />
                    <add namespace="System.Web.Mvc.Ajax" />
                    <add namespace="System.Web.Mvc.Html" />
                    <add namespace="System.Web.Routing" />
                    <add namespace="System.Web.WebPages" />
                    <add namespace="Ext.Net" />
                    <add namespace="Ext.Net.MVC" />
                    <add assembly="Ext.Net" namespace="Ext.Net" tagPrefix="ext" />
            <validation validateIntegratedModeConfiguration="true" />
            <modules runAllManagedModulesForAllRequests="true">
                <add name="DirectRequestModule" preCondition="managedHandler" type="Ext.Net.DirectRequestModule, Ext.Net" />
                <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
                <remove name="OPTIONSVerbHandler" />
                <remove name="TRACEVerbHandler" />
                <remove name="DirectRequestHandler" />
                <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
                <add name="DirectRequestHandler" verb="*" path="*/ext.axd" preCondition="integratedMode" type="Ext.Net.ResourceHandler" />
        <extnet theme="Gray" licenseKey="** Ext.NET LICENSE KEY HERE **" scriptMode="Debug" cleanResourceUrl="true" />
    (I also set <validation validateIntegratedModeConfiguration="true" /> as that is now possible, having removed the modules/handlers from system.web - and with that as true or false doesn't change anything from what I am seeing, either)

    And it is regardless whether I run in IIS (in an integrated pipeline app pool) or IIS Express (using Visual Studio defaults)
  4. #14
    Anup, please set a breakpoint on the line 409 within the HasHandler method Ext.Net\Core\ResourceHandler.cs and debug. A HasHandler call is supposed to return true with the Ext.NET resource handler is attached, otherwise - false. Debugging that method might end up with some clues what is wrong.
  5. #15
    Thanks for that Daniil.

    I think I understand a bit more now.

    Also, I was able to reproduce it with MVC Examples Explorer project that is part of the solution from SVN.

    If I run it as is, it uses the Ext.NET resource handler (ext.axd URLs appear)

    If I remove the handlers/modules from system.web then it ends up using WebResource.axd.

    I looked at the code you pointed me to, and this is what I have:

    public static bool HasHandler()
        if (HttpContext.Current.Application["Ext.Net.HasHandler"] != null)
            return (bool)HttpContext.Current.Application["Ext.Net.HasHandler"];
        bool result = false;
        string path = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, "web.config");
        XmlTextReader reader = new XmlTextReader(new StreamReader(path));
            if (reader.ReadToFollowing("httpHandlers"))
                if (reader.ReadInnerXml().Contains("type=\"Ext.Net.ResourceHandler\""))
                    result = true;
            result = false;
        HttpContext.Current.Application["Ext.Net.HasHandler"] = result;
        return result;
    What I was seeing was the the reader.ReadToFollowing is failing and jumping straight into the finally block.

    That is because it is trying to find httpHandlers, which of course has now been removed.

    So perhaps as part of removing this from web.config where IIS6 is not needed, this code needs extending to check the handler from the system.webserver section instead?
  6. #16
    Some further info:

    I edited the resource handler locally to look for "handlers" instead, and the page loaded blank.

    Looking at the source, I see links to the CSS and JavaScript created correctly, e.g.

        <link type="text/css" rel="stylesheet" href="/Ext.NET 3 Tests/extjs/packages/ext_theme_gray/build/resources/ext-theme-gray-all-embedded-css/ext.axd?v=19727" id="ext-theme" />
        <link type="text/css" rel="stylesheet" href="/Ext.NET 3 Tests/extnet/resources/css/extnet-all-debug-embedded-css/ext.axd?v=19727" id="extnet-styles" />
        <script type="text/javascript" src="/Ext.NET 3 Tests/extjs/ext-all-debug-js/ext.axd?v=19727"></script>
        <script type="text/javascript" src="/Ext.NET 3 Tests/extjs/packages/ext_theme_gray/build/ext-theme-gray-debug-js/ext.axd?v=19727"></script>
        <script type="text/javascript" src="/Ext.NET 3 Tests/extnet/extnet-all-debug-js/ext.axd?v=19727"></script>
        <script type="text/javascript" src="/Ext.NET 3 Tests/extnet/locale/ext-locale-en-GB-debug-js/ext.axd?v=19727"></script>
    But the page is just blank.

    - The CSS links return CSS
    - The two -all-debug.js files return 404 not found
    - The other JS files are loaded.

    Because the main Ext JS file is not loaded (404) we get the original Ext is undefined error...

    Hopefully that helps?
  7. #17
    So perhaps as part of removing this from web.config where IIS6 is not needed, this code needs extending to check the handler from the system.webserver section instead?
    Exactly! Thank you for spotting that! Created an Issue:

    Fixed in all the versions:
    v1: revision 6285 (branches/1).
    v2: revision 6286 (branches/2). It goes to 2.5.4.
    v3: revision 6287 (trunk). It goes to 3.1.0 beta.

    The two -all-debug.js files return 404 not found
    Hmm, I cannot reproduce that.

    Tested with only a <system.webServer> <handlers> section in Web.config and IIS Express.

    The resources links are rendered as follows:
    <link type="text/css" rel="stylesheet" href="/extjs/packages/ext_theme_gray/build/resources/ext-theme-gray-all-embedded-css/ext.axd?v=26410" id="ext-theme" />     <link type="text/css" rel="stylesheet" href="/extnet/resources/css/extnet-all-debug-embedded-css/ext.axd?v=26410" id="extnet-styles" />     <script type="text/javascript" src="/extjs/ext-all-debug-js/ext.axd?v=26410"></script>     <script type="text/javascript" src="/extjs/packages/ext_theme_gray/build/ext-theme-gray-debug-js/ext.axd?v=26410"></script>     <script type="text/javascript" src="/extnet/extnet-all-debug-js/ext.axd?v=26410"></script>
    and all of them are loaded for me.

    You could debug the ResourceHandler's ProcessRequest method. It might clarify something.
  8. #18
    I finally got a moment to look into this further.

    I have resolved it now. What I found was this:

    I went back to view source on the browser for the page failing to load the Ext JS and Ext.NET all debug scripts. In the view source I clicked on the link to the actual script include, as the browser shows the source of the link you clicked. As before, I saw the custom 404 page I had set up. What I didn't notice last time (as it was off the screen) was at the bottom was this commented out bit:

    [HttpException]: A public action method 'extnet-all-debug-js' was not found on controller 'Ext.Net3.Tests.Controllers.ExtNetController'.
       at System.Web.Mvc.Controller.HandleUnknownAction(String actionName)
       at System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState)
       at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
       at System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult)
       at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
       at System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState)
       at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
       at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
       at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
    This made me realise that it must be something to do with the routing setup/global.asax/registering routes etc.

    I compared to the NuGet version which uses WebActivatorEx. I don't have that in my test project. And without adding it, it was still not working.

    I double checked global.asax (as I was just registering the route manually without the use of WebActivatorEx).

    ExtNetConfig looks the same other than lack of the Start method that WebActivatorEx used.

    So it was global.asax:

            void Application_Start(object sender, EventArgs e)
                // Code that runs on application startup
    The above wasn't working. And then I realized. The ExtNetConfig registration has to come before the general route config registration.

    Simply swapping those lines around to the following worked:

            void Application_Start(object sender, EventArgs e)
                // Code that runs on application startup
    So I think the summary is that in a manually created project that referenced Ext.NET DLLs manually (i.e. not via NuGet) I didn't have WebActivatorFx. Registering the route using the ExtNetConfig was added manually after the default route registration (which is not right). While this took a while to spot (though slap on the head moment!) it helped lead to a leaner web.config :)

    Hope that helps others!
  9. #19
    Hi Anup,

    Nice caught! And thank you for the detailed explanation as usual. I will keep it in mind as well!

    From my best understanding, you are not expecting we should correct something in Ext.NET, aren't you?:)
  10. #20
    That's right Daniil - not expecting any changes from you.

    (I don't know if I ended up hijacking the original issue or if it was the same thing - if that can be confirmed, this post could be closed)
Page 2 of 3 FirstFirst 123 LastLast

Similar Threads

  1. Replies: 0
    Last Post: Dec 10, 2013, 3:55 PM
  2. Replies: 1
    Last Post: Nov 12, 2012, 2:29 PM
  3. [CLOSED] How to include a js/css file with ResourceManager?
    By vadym.f in forum 1.x Legacy Premium Help
    Replies: 11
    Last Post: Jun 20, 2012, 9:02 PM
  4. [CLOSED] renderScripts="File" renderStyles="File" adding extra '/'
    By SouthDeveloper in forum 1.x Legacy Premium Help
    Replies: 8
    Last Post: Nov 24, 2011, 12:23 PM
  5. [CLOSED] [1.0] ResourceManager RenderStyles / RenderScripts
    By danielg in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Mar 10, 2011, 10:45 AM

Posting Permissions