We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Setting the Authorize header to use a bearer token

Thread ID:

Created:

Updated:

Platform:

Replies:

121305 Nov 28,2015 06:38 AM Dec 8,2015 12:27 PM ASP.NET Web Forms 3
loading
Tags: Uploadbox
Pedro Salgueiro
Asked On November 28, 2015 06:38 AM

Hi,

Can you please showcase how can I intercept the request being sent to the server to add an authorization token to the request?


Kind Regards,
Pedro Salgueiro

Ezhil S [Syncfusion]
Replied On December 1, 2015 10:12 AM

Hi Pedro,

Thank you for contacting Syncfusion support.

To add an Authorization header on file upload request, we suggest you to use setRequestHeader in ClientSideOnBegin event. Using setRequestHeader you can add a header to Http request in xhr element. But for browsers below IE10 xhr will not be available in that case we suggest you to use ActiveXObject. Once the header is set you can access it in the handler from the HttpRequest.Headers. Please refer the following code example,
<code>
[ASPX]
<ej:UploadBox ID="upload1" runat="server" SaveUrl="saveFiles.ashx" RemoveUrl="removeFiles.ashx" ClientSideOnBegin="OnBegin"></ej:UploadBox>
[Script]

        function OnBegin(args) {

            if (!this._isXhrSupported()) // to check xhr supported browsers

                xhr = new ActiveXObject("Microsoft.XMLHTTP");

            else

                xhr = new XMLHttpRequest(); // IE10 and below

            xhr.open("post", "saveFiles.ashx", true);

            xhr.setRequestHeader("Authorization", "Uploadbox");

            xhr.send(null);
        }
</code>

Sample prepared can be downloaded from below link:
http://www.syncfusion.com/downloads/support/forum/121305/ze/Upload_f121231-816692230

Please let us know if you have any other queries.

Regards,
Ezhil S


Pedro Salgueiro
Replied On December 1, 2015 10:25 AM

Hi Ezhil,

I'm sorry but either I placed this thread under the wrong category (asp.net) or it was moved by mistake. 

I am using the Javascript control and not the ASP.NET control. Is the begin event equivalent? Should we set the Cancel flag to true to prevent the control from making the request?

Because this issue was quite urgent for us I have also opened the incident 147914 related with the same topic.

Kind Regards,
Pedro

Gurunathan A [Syncfusion]
Replied On December 8, 2015 12:27 PM

Hi Pedro,

We apologies for the late reply.  

We have updated our response for your query in the incident which  was created from your account. So kindly follow up the incident for further queries.

Please let me know if any concerns.

Regards,
Gurunathan

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;