I am returning http custom header from server after a user has uploaded a file. I would like to get hold of these header in the client , is it possible to get headers in onSuccess function ?
3 Answers, 1 is accepted
0
T. Tsonev
Telerik team
answered on 11 Mar 2013, 09:34 AM
Hello,
The success event contains a reference to the underlying XMLHttpRequest that provides access to the headers. The catch is that this information is not available in IE.
Our recommended solution is to return the header value as JSON. This works across browsers and is documented in the Metadata help topic.
Kind regards,
Tsvetomir Tsonev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Thanks for the pointer, i tried to return a JSON object from server with content-typ of 'text/plain'. That works in Chrome and IE9 , but breaks again in IE8.
So , to get around that , this is what i did ..
1) On first call to the server (with file content), cache the content on the server
2) Dont return any data back on the POST call as that will break in IE8
3) Make a second GET call in onSuccess event and retrieve the uploaded content .
This works , but ideally i would like to get it working in the first POST call ..
0
T. Tsonev
Telerik team
answered on 13 Mar 2013, 09:37 AM
Hello,
There shouldn't be a problem with retrieving the response in IE 8. Such response works in my tests (direct from Fiddler raw view): HTTP/1.1 200 OK
Cache-Control: private
Content-Type: text/plain; charset=utf-8
Server: Microsoft-IIS/7.5
X-AspNetMvc-Version: 3.0
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Wed, 13 Mar 2013 09:34:24 GMT
Content-Length: 15
{"Result":"OK"}
Perhaps logging the request will give us some insight on the problem.
Using a second request is a valid option, but we shouldn't need it.
Kind regards,
Tsvetomir Tsonev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!