title: Display partial view in an iframe in ASP.NET Core MVC
body: <p>I've been trying for some time to render a razor page in an IFrame in ASP.NET Core MVC 2.2.</p>
  
  <p>I have my main page and some menus that should open specific pages in my IFrame.</p>
  
  <p>The action that opens my main screen is this.</p>
  
  <pre class="lang-cs prettyprint-override"><code>[HttpGet]
  public IActionResult IndexAdm()
  {
      try
      {
          return View();
      }
      catch (Exception ex)
      {
          throw new Exception(ex.Message);
      }
  }
  </code></pre>
  
  <p>Here is the code that loads the partial view on my screen.</p>
  
  <pre class="lang-cs prettyprint-override"><code>public PartialViewResult IframeAction(string sortBy)
  {
      if (sortBy == null)
          return PartialView("../Company/ViewPartial");
      else
      {
          return PartialView(sortBy);
      }
  }
  </code></pre>
  
  <p>The first time my page loads, everything works fine. The main page is loaded and the other page is loaded into my iframe, as shown in the image below.</p>
  
  <p><a href="https://i.stack.imgur.com/qiodm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qiodm.png" alt="This is the image of the result I want to get"></a></p>
  
  <p>What I want to get is what happens above, but when I click my menu button, the main page disappears and only my partial page is loaded in the browser, as you can see in the image below.</p>
  
  <p><a href="https://i.stack.imgur.com/Gi1lW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Gi1lW.png" alt="It looks like this when I click on a menu item"></a></p>
  
  <p>My menu item code is low.</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;li&gt;
      &lt;a class="nav-link" href="#"&gt;
          &lt;i class="fas fa-question"&gt;&lt;/i&gt;
          @Html.ActionLink("FAQ", "IframeAction", "Company", new { sortBy = "../Company/ViewPartial" }, null)@*https://www.codeproject.com/Questions/1221703/How-do-I-update-an-iframe-using-ASP-NET-core*@
      &lt;/a&gt;
  &lt;/li&gt;
  </code></pre>
  
  <p>My IFrame code is below.</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;iframe id="IframeAdm" name="IFrameAdm" width="100%" height="85%" border="none" src="/Company/IframeAction"&gt;&lt;/iframe&gt;
  </code></pre>
  
  <p>How can I make my partial page render inside my iframe without my main page disappearing?</p>