title: How to refresh the page content after a Post submission on ASP.NET Core Razor Pages?
body: <p>I am using ASP Net Core, and I created a project with Razor Pages.</p>
  <p>I have a page which lists products associated with the current user, and he can add a new product.</p>
  <p><strong>After the <code>OnPost</code> method is called, I want to refresh the page so that it displays all the products of the user without requesting the database again</strong></p>
  <p>Below is my current solution:</p>
  <pre><code>    public async Task OnGet()
      {
          var currentUser = await GetCurrentUser();
          if (currentUser != null)
              Products = await _dbContext.Products.Where(x =&gt; x.AtpUserId == currentUser.Id).ToListAsync();
      }
  
      public async Task OnPost(Product product)
      {
          var currentUser = await GetCurrentUser();
          if (currentUser != null)
          {
              product.UserId = currentUser.Id;
              product.Currency = &quot;USD&quot;;
              await _dbContext.Products.AddAsync(product);
              await _dbContext.SaveChangesAsync();
              Products = await _dbContext.Products.Where(x =&gt; x.UserId == currentUser.Id).ToListAsync(); // can I avoid this ?
          }
      }
  </code></pre>
  <p>I don't find how I achieve the same result without the last line which reloads the data from the database.</p>
  <ul>
  <li>I looked at some examples but examples from the scaffold pages all use an intermediate <code>Create</code> page, and then redirect to the <code>Index</code> page. I want the user to be able to create from the Index page</li>
  <li>I tried to replace the last line of the <code>OnPost</code> method by a call to <code>RedirectToPage(&quot;Index&quot;);</code> but the method <code>OnGet</code> is not called again and the table containing the products is empty on refresh. Why?</li>
  </ul>