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.
(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.