In asp.net Web Forms, IsPostBack page property is used to check if the request is
POST or GET.
If IsPostBack Property returns true, then we knows the request
is http post. Else the request is GET
In asp.net mvc use Request object Http Method property to check
if the request is get or a Post Request
Give any Name of the controller , I have given it as Home Controller.
Write the below code in the Home Controller as shown below
As we cannot have same Index method name twice so I have used Index_Post and specifying the Action Attribute Index.
Created a new method to check Wheather IsPost() is True or False.
Right click on the controller and Add View--Index.cshtml
and click on Add Button
After hitting the url you can see that IsPostback is false
In Debugging Mode after hitting Enter.You can see that Get method is been called.
and the output is
No comments:
Post a Comment
Thank you for visiting my blog