Click here to Skip to main content
15,912,578 members

Comments by Indhu S 2021 (Top 6 by date)

Indhu S 2021 10-Aug-21 4:26am View    
Hi Richard, Unfortunately I was not able to share the Jquery as it is from Sitecore side and it has licensing issues. But you gave me an great hint about XMLHttpRequest, let me check further on this one. Thank you so much for all the prompt and highly helpful responses.
Indhu S 2021 8-Aug-21 8:22am View    
Hi Richard, Thanks for the comment.
Posting the request and response headers below. Have marked some values as "XXXXX". It is not an ajax call, but I am actually trying to download a pdf on the custom submit action of the Sitecore Forms module.

One error I used to get is that ,
"System.Web.HttpException: 'Server cannot append header after HTTP headers have been sent."
in the @Html.AntiForgeryToken() line of Forms.cshtml.

Response Headers:

cache-control: private
content-disposition: attachment; filename="MyFile.pdf"
content-type: application/pdf
date: Fri, 06 Aug 2021 14:21:15 GMT
server: Microsoft-IIS/10.0



Request headers:

:authority: XXXXXXXXXX.sc.XXXXXXXX-intra.com
:method: POST
:path: /formbuilder?fxb.FormItemId=XXXXXXXXXXXXX&fxb.HtmlPrefix=fxb.XXXXXXXXXXXXXX
:scheme: https
accept: */*
accept-encoding: gzip, deflate, br
accept-language: en,en-US;q=0.9,ar;q=0.8
content-length: 3342
content-type: application/x-www-form-urlencoded; charset=UTF-8
cookie: XXXXXXXXXXXXXRoleCookie=XXXXXXXXXX; OptanonAlertBoxClosed=2021-07-27T12:49:52.228Z;
_gcl_au=XXXXXXXXXXXXXXXX;
_ga=XXXXXXXXXXXXXXX; Disclaimer_cookie=true;
SC_ANALYTICS_GLOBAL_COOKIE=7XXXXXXXXXXXXXXX|True;
ASP.NET_SessionId=XXXXXXXXXXXXXXXXX;
FormsAuthKey=1;
__RequestVerificationToken=VXXXXXXXXXXXXXXXXXxx;
_gid=XXXXXXXXXXXXXXXXX;
OptanonConsent=isGpcEnabled=0&datestamp=Fri+Aug+06+2021+12%3A53%3A19+GMT%2B0530+(India+Standard+Time)
&version=6.20.0&isIGlobal=false&hosts=&consentId=XXXXXXXXXXXXXxx&
interactionCount=1&landingPath=NotLandingPage
&groups=1%3A1%2C2%3A1%2C3%3A1%2C4%3A1&
geolocation=%3B&AwaitingReconsent=false;
countryXX#lang=en
origin: https://XXXXX.sc.XXXXXXX-intra.com
referer: https://XXXXXXXX.sc.XXXXXXXX-intra.com/en/testformspdf
sec-ch-ua: "Chromium";v="92", " Not A;Brand";v="99", "Google Chrome";v="92"
sec-ch-ua-mobile: ?0
sec-fetch-dest: empty
sec-fetch-mode: cors
sec-fetch-site: same-origin
user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36
x-requested-with: XMLHttpRequest
Indhu S 2021 5-Aug-21 9:45am View    
Yes. I am able to view other PDF's perfectly in browser. Thank you so much Richard for constant responses. I highly appreciate that and hearty thanks for the same. I just wanted to know whether these are the only steps(or code) to download a PDF.
If that is right, there is certainly something else I should check these with overall project structure(some headers/classes or something else from other calls) affecting this.
Indhu S 2021 5-Aug-21 2:01am View    
Thanks again for your response. Yes, I tried that already and could see the same behavior across all browser(Chrome/Firefox and Edge) :(
Indhu S 2021 4-Aug-21 11:52am View    
Thanks for the response Richard!
I am seeing the response headers as given below in network tab though. So really not sure what is going wrong.

cache-control: private
content-disposition: attachment; filename="MyFile.pdf"
content-type: application/pdf
date: Wed, 04 Aug 2021 15:40:19 GMT
server: Microsoft-IIS/10.0