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;
            }
        }
Developer technologies | ASP.NET | ASP.NET Core
{count} votes

1 answer

Sort by: Most helpful
  1. Sreeju Nair 12,756 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.

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.