0

Hi i am new to web development. I know on post and get method whereby when someone browse for a hyperlink it goes to the get message whereas when someone submit a form or anything it goes to the post method to process the information. I have a simple application as below

   [HttpGet]
    public ViewResult RsvpForm()
    {
        return View();
    }

    [HttpPost]
    public ViewResult RsvpForm(GuestResponse guestResponse)
    {
        return View();
    }

The problem i facing was when click submit button without the post method which i removed it from the coding it refresh and clear the field in the form. With the post it did not clear the value in the form. Can i know why such behavior?

kevin
  • 1
  • 1

1 Answers1

0

As already thoroughly explained in bobince's response, your browser such as Chrome, Firefox or Edge is caching your data as you are POSTing your form. Data can, of course, be delivered through GET requests as well, but typically for normal forms the "correct" method would be using POST.

As you are POSTing your data to a webserver your browser will (depending on cache settings) remember these given values. When returning to the previous page (the form) your browser will recognize that for this form values were already posted and will automatically retrieve them from your cache and fill them in.

  • can i know why here put get wil cached data but post wont cached data that why was confusing https://www.w3schools.com/tags/ref_httpmethods.asp – kevin Aug 18 '18 at 14:40