This is a migrated thread and some comments may be shown as answers.

Upload onSuccess get HTTP Headers

3 Answers 205 Views
Upload
This is a migrated thread and some comments may be shown as answers.
Hafiz
Top achievements
Rank 1
Hafiz asked on 08 Mar 2013, 11:55 AM
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

Sort by
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!
0
Hafiz
Top achievements
Rank 1
answered on 11 Mar 2013, 10:09 AM
Hi Tsvetomir, 

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!
Tags
Upload
Asked by
Hafiz
Top achievements
Rank 1
Answers by
T. Tsonev
Telerik team
Hafiz
Top achievements
Rank 1
Share this question
or