title: MVC URL in Javascript Not Render Correctly
body: <p>I had a Details view which it's contain a Save and AddLine button. The AddLines button will call javascript function &quot;AddLinePopup&quot; to open a new window (&quot;window.open('./AddLine?id=' + id&quot;) with Add Line view. This was working correctly when open the Details view directly. The problem occurred when the Save button is clicked and it call to Controller (PRController) to save data and redirect back to Details view again. The URL in AddLinePopup javascript function will append the controller (&quot;'PR/Details/AddLine?id=1&quot;) when AddLine button is clicked and causing the URL error.
  I did tried using &quot;window.open('~/PR/AddLine?id=' + id')&quot;, &quot;window.open('../PR/AddLine?id=' + id')&quot; not working as well.
  How can I render the javascript AddLinePopup function URL correctly (&quot;'PR/AddLine?id=1&quot;) after Save button is clicked? Any suggestion or solution is highly appreciated. Thanks in advance.</p>
  <pre><code>//PRController
  public ActionResult Save(DetailsModel pr)
  {
       return RedirectToAction(&quot;Details&quot;, new { id = pr.ID });
  }
  
  
  //View
  @using (Html.BeginForm(&quot;Save&quot;, &quot;PR&quot;, FormMethod.Post))
  {
      &lt;input type=&quot;submit&quot; value=&quot;Save&quot; class=&quot;btn btn-primary&quot; title=&quot;Save changes&quot; /&gt;
  }
  
  @Html.ActionLink(&quot;Line&quot;, &quot;AddLine&quot;, null, new { @class = &quot;fa fa-plus-square btn btn-primary&quot;, 
  title = &quot;Add new line&quot;, onclick = &quot;AddLinePopup('&quot; + @Model.ID + &quot;');return false;&quot; })
  
  
  &lt;script type=&quot;text/javascript&quot;&gt;
       AddLinePopup = function (id) {window.open('./AddLine?id=' + id, &quot;AddLineWindow&quot;, target = '_blank','width=800px,height=650px,top=10,left=250');
  }
  &lt;/script&gt;
  </code></pre>