Thanks elishnevsky's, I am thinking if the JS files are larger (ext-all.js + manyfile.js) it could have problems, because the page delay in load, so is there some way to load the JS files on demand with this MVC approach?
Best regards
Frank
Thanks elishnevsky's, I am thinking if the JS files are larger (ext-all.js + manyfile.js) it could have problems, because the page delay in load, so is there some way to load the JS files on demand with this MVC approach?
Best regards
Frank
MVC doesn't not solve this problem. You can try search the forums for different solutions.
Eugene
Ext.Direct for ASP.NET MVC
Little more information:
Please also include in your instructions you have to add the following lines to your JS
Ext.ns('Ext.app');
Ext.Direct.addProvider(Ext.app.REMOTING_API);
For the newbies like me.
Also how do you go about setting the routerUrl when your in a sub folder (this is probably due to my lack of experience in MVC and routing) but if I have:
routerUrl="DirectRouter.ashx"
and then try so access a Script on MyDomain/Controler/Action then the 'DirectApi.ashx' get loaded correctly and when I view it I see "url": "DirectRouter.ashx"
This gives an 404 error because its looking for 'MyDomain/Controler/DirectRouter.ashx' and cannot find it because it is really in 'MyDomain/DirectRouter.ashx' I have tried adding '/' to my routerUrl but it give me errors.
For example if I also load your Demo project and go to localhost/home/Index it give an error
Thanks for the good work
dke01,
Thank you for the comment and bug report. Updated the head post. Please refer to the 'Usage' section there.
Also uploaded an updated version. Get it from the first post.
Eugene
Ext.Direct for ASP.NET MVC
Thank you for the super quick reply and fix these seems to work well.
The only other problem I seem to be having at the moment is out Action Links and website main menu (which is generated from a web.sitemap) since ALL request seem to be getting routed via your handeller it seems to be changing normal hyperlinks like
/Controller/Action to now be DirectRouter.ashx?control=xxx?action=yyy
Which then seems to break all the links? Not sure if there is someway to circumvent this behaviour? I do not have time to look at your source code and attempt to fix this myself at this stage but may later if I have time.
Thanks again for your assistance.
dke01,
Thank you very much for testing and reporting bugs! The issue you described should be fixed now.
BTW, it isn't true that all requests are routed via my handler. It's just that my custom route definitions were not complete. They are now, I hope
Please download updated version from the first post.
Eugene
Ext.Direct for ASP.NET MVC
Hi, I'm testing Ext.Direct MVC and have a problem. I configured everything as described here, built a controller and try to call the test method, but the DirectProvider has a problem with deserializing request body:
Newtonsoft.Json.JsonSerializationException was unhandled by user code
Message="Expected a JsonObjectContract or JsonDictionaryContract for type 'System.Collections.Generic.List`1[Ext.Direct.Mvc.DirectRequest]', got 'Newtonsoft.Json.Serialization.JsonArrayContract'."
Source="Newtonsoft.Json"
StackTrace:
at Newtonsoft.Json.Serialization.JsonSerializerReader.CreateObject(JsonReader reader, Type objectType, Object existingValue) in d:\Newtonsoft\Projects\Json\trunk\Src\Newtonsoft.Json\Serialization\JsonSerializerReader.cs:line 307
at Newtonsoft.Json.Serialization.JsonSerializerReader.CreateValue(JsonReader reader, Type objectType, Object existingValue, JsonConverter memberConverter) in d:\Newtonsoft\Projects\Json\trunk\Src\Newtonsoft.Json\Serialization\JsonSerializerReader.cs:line 164
at Newtonsoft.Json.Serialization.JsonSerializerReader.Deserialize(JsonReader reader, Type objectType) in d:\Newtonsoft\Projects\Json\trunk\Src\Newtonsoft.Json\Serialization\JsonSerializerReader.cs:line 94
at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType) in d:\Newtonsoft\Projects\Json\trunk\Src\Newtonsoft.Json\JsonSerializer.cs:line 344
at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings) in d:\Newtonsoft\Projects\Json\trunk\Src\Newtonsoft.Json\JsonConvert.cs:line 631
at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings) in d:\Newtonsoft\Projects\Json\trunk\Src\Newtonsoft.Json\JsonConvert.cs:line 595
at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value) in d:\Newtonsoft\Projects\Json\trunk\Src\Newtonsoft.Json\JsonConvert.cs:line 552
at Ext.Direct.Mvc.DirectProvider.Execute(RequestContext requestContext) in C:\dev\ExtDirectMVC\source\Ext.Direct.Mvc\Ext.Direct.Mvc\DirectProvider.cs:line 119
at Ext.Direct.Mvc.DirectMvcHandler.ProcessRequest(HttpContextBase httpContext) in C:\dev\ExtDirectMVC\source\Ext.Direct.Mvc\Ext.Direct.Mvc\DirectMvcHandler.cs:line 51
at System.Web.Mvc.MvcHandler.ProcessRequest(HttpContext httpContext)
at System.Web.Mvc.MvcHandler.System.Web.IHttpHandler.ProcessRequest(HttpContext httpContext)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
The method I'm trying to call:
And my javascript invocation:Code:public class DirectRPCController : Ext.Direct.Mvc.DirectController { public ActionResult Test1(string data) { return Direct(new {Ala = "nie ma kota" }); } }
Json that is sent to the server looks like so:Code:DirectRPC.Test1("ziutek");
Something is wrong with JSon deserialization code in DirectProvider - this line fails:Code:{\"action\":\"DirectRPC\",\"method\":\"Test1\",\"data\":[\"ziutek\"],\"type\":\"rpc\",\"tid\":2}
Can you help?Code:var requests = JsonConvert.DeserializeObject<List<DirectRequest>>(json);
PS. I have some hint - probably the deserialization code expects an array of Json objects and the Json contains just a single object. When I tested a deserialize call with single DirectRequest, not a list:
it worked correctly and deserialized the Json as DirectRequest. So there's probably some mismatch between client-side and server-side code, either client-side should send a Json array, or the server should expect either an array or a single Json object.Code:JsonConvert.DeserializeObject<DirectRequest>(json)
Hint 2: I'm using the latest version of Newtonsoft.Json dll 3.5.0.0
I'm not sure why your JSON request contains backslashes in it. I guess it is what causes the crash. My JSON requests don't have backslashes:
Code:{"action":"Employees","method":"Get","data":[0,10,"Name","ASC"],"type":"rpc","tid":2}
Eugene
Ext.Direct for ASP.NET MVC
Ok, just tested you JSON string and backslashes have nothing to do with it.
The deserialization to List<DirectRequest> doesn't crash, it returns empty list (count = 0) and that's what I'm checking on the next line. It works fine for me. I really don't know what causes your crash.
I have added these 3 lines in the Index() action of HomeController in my TestApplication and they work fine:
Code:string json = "{\"action\":\"DirectRPC\",\"method\":\"Test1\",\"data\":[\"ziutek\"],\"type\":\"rpc\",\"tid\":2}"; var listOfRequests = JsonConvert.DeserializeObject<List<DirectRequest>>(json); var singleRequest = JsonConvert.DeserializeObject<DirectRequest>(json);
Eugene
Ext.Direct for ASP.NET MVC
Backslashes are there because I copied the json string from Visual Studio debugger and it escapes the string content in 'Quick View' window - the real Json doesn't contain them