Refresh Page after Submit (POST) Razor Pages

Imran Jalali 101 Reputation points
2021-07-01T11:13:50.55+00:00

Hi Friends.

I am deleting a record in the OnPost event of ASP.NET Razor Page. The problem is that the page doesn't refresh itself after submitting... I try to call OnGet method and rebinding my model but that doesn't help.

I found one solution ASPNet-Core-Razor-Pages-Refresh-Page-after-Submit-POST.aspx
It works fine after first submit

Please look at my code and help me please.

Thanks.

public void OnPostDeleteReg(int CommitteeRegId)
        {
            try
            {
                CommitteeBO ComitteDesc = new CommitteeBO(_configuration);
                int UserId = _appuser.UserID;    
                ComitteDesc.Delete(CommitteeRegId, UserId);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,166 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Sreeju Nair 11,606 Reputation points
    2021-09-07T12:08:13.407+00:00

    Is your code get executed? If yes, change void to IActionResult and then return Page()

    2 people found this answer helpful.