question

ImranJalali-0706 avatar image
0 Votes"
ImranJalali-0706 asked sreejukg answered

Refresh Page after Submit (POST) Razor Pages

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;
             }
         }


dotnet-aspnet-core-razor
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Unless you're doing an AJAX request, a POST certainly refreshes the page. If your design does use AJAX, then the problem is you did not write any code to update the Razor Page's model.

0 Votes 0 ·

1 Answer

sreejukg avatar image
1 Vote"
sreejukg answered

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

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.