title: How to prevent extra request if pdf requested refreshed in browser
body: <p>ASP.NET MVC 4 controller returs pdf:</p>
  
  <pre><code>public class ReportController : ControllerBase
  {
  
      public ActionResult Pdf()  {
  
          byte[] result = CreatePDF();
          var ms = new MemoryStream(result);
          return new FileStreamResult(ms, "application/pdf");
      }
   }
  </code></pre>
  
  <p>Results appears in Chrome browser window.
  If this url is invoked or refresh button is pressed in browser, Chrome calls Pdf controller two times:</p>
  
  <p><a href="https://i.stack.imgur.com/ROger.png" rel="nofollow"><img src="https://i.stack.imgur.com/ROger.png" alt="enter image description here"></a></p>
  
  <p>developer tools shows that second request is cancelled.</p>
  
  <p>Pdf creation takes lot of time in controller.
  How to force browser to send single request only ?
  Or how to dedect fake request in controller and not generate pdf in this case ?</p>
  
  <p><strong>Update</strong></p>
  
  <p>page is defined as</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  
  &lt;html&gt;
  &lt;head&gt;
      &lt;meta charset="utf-8" /&gt;
      &lt;meta http-equiv="X-UA-Compatible" content="IE=edge" /&gt;
      &lt;meta name="viewport" content="width=device-width, initial-scale=1" /&gt;
      &lt;link href="/css/redmond/jquery-ui.css" rel="stylesheet" /&gt;
      &lt;link href="/Content/font-awesome.min.css" rel="stylesheet" /&gt;
      &lt;link href="/Content/bootstrap.css" rel="stylesheet" /&gt;
      &lt;link href="/Content/bootstrap-theme.css" rel="stylesheet" /&gt;
      &lt;link href="/Scripts/jqgrid-4.9.1/css/ui.jqgrid.css" rel="stylesheet" /&gt;
      &lt;link href="/Content/Css/Site.css" rel="stylesheet" /&gt;
      &lt;script src="/Scripts/jquery-1.12.4.js"&gt;&lt;/script&gt;
      &lt;script src="/Scripts/jquery-ui-1.11.4.js"&gt;&lt;/script&gt;
      &lt;script src="/Scripts/i18n/jquery.ui.datepicker-et.js"&gt;&lt;/script&gt;
      &lt;script src="/Scripts/bootstrap.js"&gt;&lt;/script&gt;
      &lt;script src="/Scripts/jqgrid-4.9.1/js/i18n/grid.locale-et.js"&gt;&lt;/script&gt;
      &lt;script src="/Scripts/jqgrid-4.9.1/js/jquery.jqgrid.src.js"&gt;&lt;/script&gt;
      &lt;script src="/Scripts/jqgrid-4.9.1/plugins/jquery.jqgrid.showhidecolumnmenu.js"&gt;&lt;/script&gt;
      &lt;script src="/Scripts/jqgrid-4.9.1/plugins/jquery.contextmenu-ui.js"&gt;&lt;/script&gt;
      &lt;script src="/Scripts/jqgrid-4.9.1/plugins/jquery.createcontexmenufromnavigatorbuttons.js"&gt;&lt;/script&gt;
      &lt;script src="/Scripts/json2.js"&gt;&lt;/script&gt;
      &lt;script src="/Scripts/jquery.form.js"&gt;&lt;/script&gt;
      &lt;script src="/Scripts/myerp.js"&gt;&lt;/script&gt;
      &lt;script src="/Scripts/TinyMCE/tiny_mce.js"&gt;&lt;/script&gt;
      &lt;script src="/Scripts/TinyMCE/jquery.tinymce.js"&gt;&lt;/script&gt;
     ...
  &lt;/head&gt;
  &lt;body&gt;
     ...
      &lt;div class="container-fluid"&gt;
          &lt;form id="_form" target="_blank" class='form-inline'&gt;
              &lt;div class="panel panel-warning"&gt;
                  &lt;div id='contentCaptionDiv' class="panel-heading"&gt;
                          &lt;input type="submit" id='_submit' class="btn btn-primary"
                                 formaction='/Report/Html'
                                 formtarget="_blank"
                                 value='Show html' /&gt;
  
                          &lt;input type="submit"
                                 formaction='/Report/Pdf'
                                 class="btn btn-info"
                                 formtarget="_blank"
                                 value='PDF' /&gt;
                          &lt;input type="submit"
                                 formaction='/Report/Xls'
                                 class="btn btn-warning"
                                 formtarget="_blank"
                                 value='CSV' /&gt;
                          &lt;input type="submit"
                                 formaction='/Report/Designer?_entity=DokGReport&amp;amp;_dokumnrs=130637'
                                 formtarget="_blank"
                                 class="btn btn--inverse"
                                 value='Change' /&gt;
                          ...
                          &lt;script&gt;
                      $(function () {
                          var lastFocus = [];
                          var elements = getFocusableElements();
                          elements.focus(function () {
                              lastFocus = $(this);
                          });
                          $('#_form').keypress(function (e) {
                              if (enter(e)) {
                                  $('#_submit').click();
                                  return false;
                              }
                          });
  
                          $('#sendemail').click(function (e) {
  
                              $('#_form').attr('action', $(this).attr('formaction'))
                                   .attr('target', $(this).attr('formtarget'));
                          });
  
  
  
                          elements.eq(0).focus().select();
  
                          $('#_Report').dblclick(function () {
                              $('#_submit').click();
                          });
  
  
                          $('#_form').on('click', 'input[type=submit]', function (e) {
                              var attr = this.getAttribute('formAction');
                              if (attr) {
                                  this.form.action = attr;
                              }
                          });
  
                      });
                      &lt;/script&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/form&gt;
      &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>