Email: Password:       Forgot Password 
    .netCodeSG
A Saarsha Group Online Community for dot net codes group like C#, Asp.NET, VB.NET, Sharepoint, JavaScript, JQuery, Ajax, SQL, WCF, WPF.
 
TECHNOLOGIES:
Difference between Get and post method type in Controller in ASP.NET MVC.
  Comment
 
 
cscs
On  20/10/2015 20:08:29
cscs
On  20/10/2015 20:08:29
1. GET is supposed to be for Read-only actions and Post is supposed to be for actions that modify the database. But this is just a "best practice" (nothing enforces this rule. Nothing will prevent you from modifying the database from an [HttpGet] method). 

2. GET keeps its variables in the querystring. POST keeps its variables in the form. But I have seen this method signature in a training guide where a [HttpPost] method is referencing the id parameter in the querystring:
[HttpPost]
public ActionResult DeleteConfirmed(int id = 0)
{
Movie movie = db.Movies.Find(id);
db.Movies.Remove(movie);
db.SaveChanges();
return RedirectToAction("Index");
}


3. The GET method is fired when the user clicks on a hyperlink on your form. The POST method is fired when the user clicks on a <input type="submit"> control on your form.
On  23/08/2015 01:23:25
GET Method: 

1.All the name value pairs are submitted as a query string in URL. 
It's not secured as it is visible in plain text format in the Location bar of the web browser. 

2.Length of the string is restricted. 

3.If get method is used and if the page is refreshed it would not prompt before the request is submitted again. 

4.One can store the name value pairs as bookmark and directly be used while sharing with others - example search results. 


POST Method: 

1. All the name value pairs are submitted in the Message Body of the request. 

2. Length of the string (amount of data submitted) is not restricted. 

3. Post Method is secured because Name-Value pairs cannot be seen in location bar of the web browser. 

4. If post method is used and if the page is refreshed it would prompt before the request is resubmitted. 

5. If the service associated with the processing of a form has side effects (for example, modification of a database or subscription to a service), the method should be POST. 

6. Data is submitted in the form as specified in enctype attribute of form tag and thus files can be used in FileUpload input box.  
On  23/08/2015 01:22:11
MOST VIEWED QUESTION:
 
         HOME   |   Submit Article   |   Contact Us   |   About Us   |   Terms & Condition   |   Advertise With us