View Full Version : Ext.Direct and Form Methods

26 Aug 2009, 6:18 AM
Can I please see a working example / string of what Ext.Direct expects to see on a form request? (Specifically I'm doing a file upload, but any form request will do.)

I'm using my branch of the .NET Ext.Direct stack and looking at the sample project for the stack, I don't believe its actually working for the file upload. I am getting an error when its trying to decode the response JSON that comes back.

The spec says that the response json on an upload needs to come back in a textarea field in a mocked up HTML response. But I'm trying to trace through the code and I'm not seeing any evidence in the Ext.Direct code that its recognizing this format and trying to parse out just the textarea. Instead, it's trying to Ext.decode the whole chunk of html, which of course fails.

What am I missing? If there is a sample of what a server should respond with after a file upload via a form method, can someone please point me to it? I can then make the .NET Ext direct stack follow that format.


26 Aug 2009, 6:53 AM
Yeah, I'm going through the code and I'm not seeing ANY evidence that the JsonProvider is trying to do anything differently with the response from a Form Upload. The Ext.Direct page says:

If the request was a form post and it was an upload the response will be sent back as a valid html document with the following content:

<html><body><textarea>{YOUR JSON RESPONSE HERE}</textarea></body></html>

&quot; must be back-slashed because the textarea will convert them to actual quotes. Therefore you must do a regular expression (/"/, "\"")

The response will be encoded as JSON and be contained within the textarea.

But, from what I'm tracing in the code, the response is filtering down to Ext.direct.JsonProvider.parseResponse, which is then running

return Ext.decode(xhr.responseText);

directly on the responseText, which contains HTML. It should be recognizing that this is an Upload request and that it needs to find and parse out the TextArea's contents.

What am I missing here? Is this a bug / unfinished feature? Or am I just looking down the wrong rabbit hole?

26 Aug 2009, 7:06 AM
Sigh. Never mind. Chasing my tail because of a bug in the Ext.Direct .Net stack. It's specifying a text/javascript content type, which throws off Ext when the response comes back. I think this line in the sample should be commented out:

context.Response.ContentType = DirectHandlerContentType;

Will post this also over on the stack's thread.

2 Sep 2009, 9:43 AM
Did you ever get file uploading working with your Ext.Direct .Net stack?

If so, did you update your code?

2 Sep 2009, 12:07 PM
It's not a bug in the stack, its a bug in the implementation of the stack in the samples. See here: http://www.extjs.com/forum/showthread.php?p=379163#post379163

13 Sep 2009, 6:42 PM
Thanks for sharing infor here