title: asp.net mvc window open with custom properties and model
body: <p>I have a form with submit, which opens a pdf file</p>
  
  <pre><code>@using (Html.BeginForm(null, null, new { ReturnUrl = ViewBag.ReturnUrl }, FormMethod.Post, htmlAttributes: new { @class = "custom" }))
    {
     ......
     @Html.TextboxFor(m=&gt;m.Name)
     &lt;input type="submit" value="Open File"/&gt;
    }
  </code></pre>
  
  <p>I want this to open the file in a new window.<br>
  - I need to pass the model to the post method (solution1)<br>
  - I can open the new window but i also need to name it and re-open a file in the same window. (solution2)  </p>
  
  <p>I have the 2 possible solutions but I want to combine their features.</p>
  
  <p><code>solution1:</code></p>
  
  <pre><code>@using (Html.BeginForm(null, null, new { ReturnUrl = ViewBag.ReturnUrl }, FormMethod.Post, htmlAttributes: new { @class = "custom" }))
    {
     ......
     @Html.TextboxFor(m=&gt;m.Name)
     &lt;input type="submit" value="Open File" formtarget="_blank"/&gt;
    }
  </code></pre>
  
  <p><code>solution2:</code></p>
  
  <pre><code>    @using (Html.BeginForm(null, null, new { ReturnUrl = ViewBag.ReturnUrl }, FormMethod.Post, htmlAttributes: new { @class = "custom" }))
    {
      ......
      @Html.TextboxFor(m=&gt;m.Name)
      &lt;a href="#" onclick="fileDownload()" &gt;Download File&lt;/a&gt;
    }
  
  &lt;script type="text/javascript"&gt;
      function fileDownload() {
  
          var title = "my file";
  
          var win = window.open("@Url.Action("DisplayFile", "MyFile")?name=@Model.Name", title);
          win.onload = function () { this.document.title = title; };
      };
  &lt;/script&gt;
  </code></pre>
  
  <p>In <code>Solution2</code> i don't want to pass model as url parameters, i want it to be a <code>POST</code> call.<br>
  In <code>Solution1</code> i can't seem to customize the <code>title</code> of the new window.  </p>
  
  <p>Either of the solutions are fine by me, so if someone can figureout one of them or a combination i'll just use that.</p>
  
  <p>EDIT: updated with sample model value</p>