extjs - ASP.NET Generic Handler not getting called after .NET 3.5 to .NET 4.0 upgrade -


this old title describes visible issue, new title describes root cause issue little better. i'm still not sure why ashx isn't getting called, i'm still looking answer. have workaround hard coding api descriptor (ext.app.remoting_api variable). got json object (ext.app.remoting_api variable) directproxy "provider" returned variable, original code running .net 3.5. used online javascript beautifier make beautiful (so can read it, instead of being on single line).

old title: extjs 3 ext.direct proxy error: uncaught typeerror: cannot read property 'events' of undefined

i upgraded extdirect4dotnet project .net 3.5 .net 4.0. project , sample project can found here https://code.google.com/p/extdirect4dotnet/. when did this, had temporarily copy web.config file when changed project version. fixed parameter list of 2 override methods due inheriting class in json.net found @ http://json.codeplex.com/sourcecontrol/latest#readme.txt. fixed way dll references being made in both projects. replaced occurances of "3.5" "4.0" in web.config.

unfortunately, project uses extjs 3.0.0, not extjs 4.2.* framework version i'm implementing ext.direct proxy .net server-side stack (extdirect4dotnet) with. still uses old syntax. below i'm trying figure out how fix particular error after .net upgrade. it's still using extjs 3.0.0. see "see line" in "addprovider" function see line it's failing on. when debug javascript, "provider" undefined. guess doesn't know how provider ext.app.remoting_api after upgraded .net 4.0.

javascript error:

uncaught typeerror: cannot read property 'events' of undefined  

extjs code:

/*!  * ext js library 3.0.0  * copyright(c) 2006-2009 ext js, llc  * licensing@extjs.com  * http://www.extjs.com/license  */ 

...

 * </code></pre>  * @param {object/array} provider accepts either array of provider descriptions (an instance  * or config object provider) or number of provider descriptions arguments.  each  * provider description instructs ext.direct how create client-side stub methods.  */ addprovider : function(provider){             var = arguments;     if(a.length > 1){         for(var = 0, len = a.length; < len; i++){             this.addprovider(a[i]);         }         return;     }      // if provider has not been instantiated     if(!provider.events){  // <========================= see line         provider = new ext.direct.providers[provider.type](provider);     }     provider.id = provider.id || ext.id();     this.providers[provider.id] = provider;      provider.on('data', this.onproviderdata, this);     provider.on('exception', this.onproviderexception, this);       if(!provider.isconnected()){         provider.connect();     }      return provider; }, 

sample project javascript code:

ext.direct.addprovider(ext.app.remoting_api);  

screen shot of javascript debugger on "provider" object .net 3.5 implementation (before .net upgrade)

(open in new window see larger image)

enter image description here

as workaround, i've done following js file , hard coded provider (ext.app.remoting_api variable). json object api descriptor. captured variable "provider" inherited ashx code below when sample project configured .net 3.5. strange reason, generic handler in asp.net not getting called. class generic handler inheriting seems normal .net 4.0 generic handler (ashx) code me. i've pasted html, ashx , inherited ashx below.

ext.onready(function () {      ext.app.remoting_api = {         "type": "remoting",         "id": "1",         "url": "../directrouter.ashx",         "actions": {             "calltypes": [{                 "name": "echo",                 "len": 1,                 "formhandler": false             }, {                 "name": "gettime",                 "len": 0,                 "formhandler": false             }, {                 "name": "uploadhttprequestparam",                 "len": 1,                 "formhandler": true             }, {                 "name": "uploadnamedparameter",                 "len": 1,                 "formhandler": true             }, {                 "name": "savemethod",                 "len": 3,                 "formhandler": false             }, {                 "name": "savemethod_form",                 "len": 1,                 "formhandler": true             }, {                 "name": "datesample",                 "len": 2,                 "formhandler": false             }],             "treeaction": [{                 "name": "getchildnodes",                 "len": 2,                 "formhandler": false             }],             "crudsamplemethods": [{                 "name": "create",                 "len": 1,                 "formhandler": false             }, {                 "name": "read",                 "len": 1,                 "formhandler": false             }, {                 "name": "update",                 "len": 2,                 "formhandler": false             }, {                 "name": "destroy",                 "len": 1,                 "formhandler": false             }, {                 "name": "reset",                 "len": 0,                 "formhandler": false             }]         }     };       ext.direct.addprovider(ext.app.remoting_api);     //ext.direct.addprovider();      var employee = ext.data.record.create([         { name: 'firstname' },                  // map record's "firstname" field row object's key of same name         {name: 'job', mapping: 'occupation'}  // map record's "job" field row object's "occupation" key     ]);      var reader = new ext.data.jsonreader({         totalproperty: 'results',         successproperty: 'success',         idproperty: 'id',         root: 'data'     }, [             { name: 'id' },             { name: 'email', allowblank: false },             { name: 'first', allowblank: false },             { name: 'last', allowblank: false }         ]     );     var writer = new ext.data.jsonwriter({         returnjson: false,         writeallfields: true     });      var store = new ext.data.directstore({         api: {             read: crudsamplemethods.read,             create: crudsamplemethods.create,             update: crudsamplemethods.update,             destroy: crudsamplemethods.destroy         },         reader: reader,         baseparams: { dummy: 'blubb' },         writer: writer,     // <-- plug datawriter store reader         paramsashash: true,         batchsave: false,         batch: false,         prettyurls: false,         remotesort: true,         listeners: {             load: function (result) {             },             loadexception: function () {              },             scope:         }     });     //      var mypagesize = 10;      var usercolumns = [         { header: "id", width: 40, sortable: true, dataindex: 'id' },         { header: "email", width: 100, sortable: true, dataindex: 'email', editor: new ext.form.textfield({}) },         { header: "first", width: 50, sortable: true, dataindex: 'first', editor: new ext.form.textfield({}) },         { header: "last", width: 50, sortable: true, dataindex: 'last', editor: new ext.form.textfield({}) }     ];     ext.onready(function () {         ext.quicktips.init();          var userform = new app.user.form({             renderto: 'user-form',             listeners: {                 create: function (fpanel, data) {   // <-- custom "create" event defined in app.user.form class                     var rec = new usergrid.store.recordtype(data);                     usergrid.store.insert(0, rec);                 }             }         });          // create user.grid instance (@see usergrid.js)         var usergrid = new app.user.grid({             renderto: 'user-grid',             store: store,             columns: usercolumns,             bbar: new ext.pagingtoolbar({                 store: store,       // grid , pagingtoolbar using same store                 displayinfo: true,                 pagesize: mypagesize,                 prependbuttons: true,                 items: [                     'text 1'                 ]             }),             listeners: {                 rowclick: function (g, index, ev) {                     var rec = g.store.getat(index);                     userform.loadrecord(rec);                 },                 destroy: function () {                     userform.getform().reset();                 }             }         });         settimeout(function () {             ext.get('loading').remove();             ext.fly('loading-mask').fadeout({                 remove: true             });             store.load({ params: {                 start: 0,          // specify params first page load if using paging                 limit: mypagesize,                 foo: 'bar'             }             });          }, 250);     });  });   // onready 

html code:

...

<link rel="stylesheet" type="text/css" href="../ext/resources/css/ext-all.css" />     <script type="text/javascript" src="../ext/ext-base-debug.js"></script>      <script type="text/javascript" src="../ext/ext-all-debug.js"></script> <!-- directproxy.rfc registred in web.config --> <script type="text/javascript" src="../directproxy.ashx"></script> 

...

ashx:

using system;

using system.collections; using system.data; using system.linq; using system.web; using system.web.services; using system.web.services.protocols; using system.xml.linq; using extdirect4dotnet;  namespace webapplication1 {    /// <summary>     /// zusammenfassungsbeschreibung für $codebehindclassname$     /// </summary>     [webservice(namespace = "http://tempuri.org/")]     [webservicebinding(conformsto = wsiprofiles.basicprofile1_1)]     public class directproxy : directproxy     {         public directproxy()         {             directproxy.routerurl = "../directrouter.ashx";         }      } } 

inherited ashx found within extdirect4dotnet (code didn't change during .net 4.0 upgrade):

using system; using system.collections.generic; using system.linq; using system.text; using system.web; using system.configuration; using system.web.configuration; using extdirect4dotnet; using extdirect4dotnet.helper;  namespace extdirect4dotnet {     /// <summary>     /// represents proxy ext.direct comunication.     /// tha proccessrequest methode scanns available assembly classes , methods      /// direct attribute.     /// </summary>     public class directproxy : ihttphandler     {         private static string url = "";         public static string routerurl {             { return url; }             set { url = value; }         }          public static directprovider getdirectprovidercache(string apinamespace)         {              string routerurl = (directproxy.routerurl == "") ? configurationcache.getrouterurl() : directproxy.routerurl;              // set default namspace remoting api             string apinamespace = (apinamespace == null || apinamespace == "") ? "ext.app.remoting_api" : apinamespace;               directprovidercache cache = directprovidercache.getinstance();             directprovider provider;              //after being configured, provider should cached.             if (!cache.containskey(apinamespace + "/" + routerurl))             {                 provider = new directprovider(apinamespace, routerurl);                 provider.configure(appdomain.currentdomain.getassemblies());                 if (!cache.containskey(apinamespace + "/" + routerurl))                     cache.add(apinamespace + "/" + routerurl, provider);             }             else             {                 provider = cache[apinamespace + "/" + routerurl];             }             return provider;         }          public void processrequest(httpcontext context)         {               // set default namspace remoting api             string apinamespace = "ext.app.remoting_api";             if (context.request.form["ns"] != null)             {                 // if there namespace parameter, use it...                 apinamespace = context.request.form["ns"].tostring();             }             directprovider provider = getdirectprovidercache(apinamespace);              context.response.write(provider.tostring());              /*             old code..               // set response typ javascript since responce gets parsed script tag             context.response.contenttype = "text/javascript";              string rem = "{";             rem += "url: \""+routerurl+"\",";             rem += "type:\"remoting\",";               //string json = directproxygenerator.generatedirectapi();            //rem += json;             rem += "};";              rem = apinamespace + ".remoting_api =" + rem;             rem = "(function(){" + rem + "})();";              context.response.write(rem);            */         }          public bool isreusable         {             { return false; }         }     } } 

solved both iis 6 , iis 7, after reproducing issue in iis 7!!

the http handlers work on iis 6 .net 3.5 , .net 4.0. however, when upgrade framework .net 4.0, http handlers break on iis 7. in order fix, must 4 things.

1.) change application pool .net version v2.0 v4.0

2.) change application pool integrated classic

3.) change application pool 64 bit 32 bit

4.) replace xml tag in web.config. if don't , replace "3.5.0.0" version these lines "4.0.0.0", can corrupt iis , throw error.

configuration file not well-formed xml #2

.net version 3.5 web.config configuration:

(notice lowercase versus uppercase letters in "publickeytoken" attribute value)

  <!--<configsections>     <sectiongroup name="system.web.extensions" type="system.web.configuration.systemwebextensionssectiongroup, system.web.extensions, version=3.5.0.0, culture=neutral, publickeytoken=31bf3856ad364e35">       <sectiongroup name="scripting" type="system.web.configuration.scriptingsectiongroup, system.web.extensions, version=3.5.0.0, culture=neutral, publickeytoken=31bf3856ad364e35">         <section name="scriptresourcehandler" type="system.web.configuration.scriptingscriptresourcehandlersection, system.web.extensions, version=3.5.0.0, culture=neutral, publickeytoken=31bf3856ad364e35" requirepermission="false" allowdefinition="machinetoapplication"/>         <sectiongroup name="webservices" type="system.web.configuration.scriptingwebservicessectiongroup, system.web.extensions, version=3.5.0.0, culture=neutral, publickeytoken=31bf3856ad364e35">           <section name="jsonserialization" type="system.web.configuration.scriptingjsonserializationsection, system.web.extensions, version=3.5.0.0, culture=neutral, publickeytoken=31bf3856ad364e35" requirepermission="false" allowdefinition="everywhere"/>           <section name="profileservice" type="system.web.configuration.scriptingprofileservicesection, system.web.extensions, version=3.5.0.0, culture=neutral, publickeytoken=31bf3856ad364e35" requirepermission="false" allowdefinition="machinetoapplication"/>           <section name="authenticationservice" type="system.web.configuration.scriptingauthenticationservicesection, system.web.extensions, version=3.5.0.0, culture=neutral, publickeytoken=31bf3856ad364e35" requirepermission="false" allowdefinition="machinetoapplication"/>           <section name="roleservice" type="system.web.configuration.scriptingroleservicesection, system.web.extensions, version=3.5.0.0, culture=neutral, publickeytoken=31bf3856ad364e35" requirepermission="false" allowdefinition="machinetoapplication"/>         </sectiongroup>       </sectiongroup>     </sectiongroup>   </configsections>--> 

.net version 4.0 web.config configuration:

  <configsections>     <sectiongroup name="system.web.extensions" type="system.web.configuration.systemwebextensionssectiongroup, system.web.extensions, version=4.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35">       <sectiongroup name="scripting" type="system.web.configuration.scriptingsectiongroup, system.web.extensions, version=4.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35">         <section name="scriptresourcehandler" type="system.web.configuration.scriptingscriptresourcehandlersection, system.web.extensions, version=4.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35" requirepermission="false" allowdefinition="machinetoapplication"/>         <sectiongroup name="webservices" type="system.web.configuration.scriptingwebservicessectiongroup, system.web.extensions,  version=4.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35">           <section name="jsonserialization" type="system.web.configuration.scriptingjsonserializationsection, system.web.extensions, version=4.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35" requirepermission="false" allowdefinition="everywhere"/>           <section name="profileservice" type="system.web.configuration.scriptingprofileservicesection, system.web.extensions, version=4.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35" requirepermission="false" allowdefinition="machinetoapplication"/>           <section name="authenticationservice" type="system.web.configuration.scriptingauthenticationservicesection, system.web.extensions, version=4.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35" requirepermission="false" allowdefinition="machinetoapplication"/>           <section name="roleservice" type="system.web.configuration.scriptingroleservicesection, system.web.extensions, version=4.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35" requirepermission="false" allowdefinition="machinetoapplication"/>         </sectiongroup>       </sectiongroup>     </sectiongroup>   </configsections> 

related to:

https://serverfault.com/questions/525443/how-to-uninstall-iis-from-windows-server-2008/525496#525496

configuration file not well-formed xml #2


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -