Looking for the best practices to tackle a user behavior in my Sitecore 7.5 application.

Basically there is an action method decorated with the [HttpPost] attribute. This action is invoked through client side for generating a PDF.

Ex. https://www.XYZ.com/api/sitecore/ArchiveController/DisplayPDF

(i) When this action is invoked from the client, the Pdf gets streamed as expected to the browser, having the string (https://www.XYZ.com/api/sitecore/ArchiveController/DisplayPDF) displayed in the browser url.

(ii) Now considering a situation where the streaming of the PDF takes time (archive server latency, network issues etc), the user selects the url in the browser and manually presses ENTER. The browser instead considers this as a valid sitecore item GET request and tries to fetch item with (/api/sitecore). Which obviously not being there throws a static 500 error 404 not found


Server Error 404 - File or directory not found. The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.

(iii) Instead, if user just refreshed the browser through the REFRESH button, browser reposts the url with Sitecore Ajax post action and executes the PDF generation again.

With the increased traffic on our website, more users are complaining of the 404 errors due to this behavior.

While we are still addressing the underlying concern of slow PDF rendering on the browser, from a prevention point of view, what are the recommended ways I can restrict user from explicitly executing the url by pressing enter on the browser? Two approaches I can think of here -

(i) Changing the url to be more Sitecore friendly.

(ii) Intercepting the HttpRequest pipleline and handle the request to fetch /api/sitecore item there.

  • What about when the PDF needs to be generated you tell the user that you'll send them an email when it's ready. If the PDF is already available then you would prompt the download. Feb 19, 2018 at 1:29
  • Mike thats what we already do. On the client side the download button is only visible when pdf is available. The download button then eventually executes the sitecore ajax post request. The issue here is the url, even the user successfully views pdf user may still click enter on the browser making an invalid GET call to fetch non existing sitecore item.
    – Abhi
    Feb 19, 2018 at 4:30
  • Try to find a way to deliver the pdf's with a get method instead of a post.. That would indeed change the url probably.
    – Gatogordo
    Feb 19, 2018 at 8:09
  • May be you can try to check the source of action to avoid direct access of ajax call.
    – Amit Kumar
    Feb 19, 2018 at 16:18


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.