How to differentiate get requests from post requests

Source: Internet
Author: User

The problem with learning MVC today is how to differentiate whether a request is a GET request or a POST request, and I hope to share it with you.

When I request a method of a controller class in a view, sometimes it is necessary to have a method of the same name, but to distinguish between the two methods. So I added [HttpPost] and [HttpGet] in front of the method to distinguish between a get or a POST request.

[HttpPost]
Public ActionResult Permissionson (formcollection form) {}

[HttpGet]
Public ActionResult Permissionson () {}

Then came the problem that bothered me, I visited this controller method, but this is not like a form can specify the post or get Submit method, I originally thought that after the URL parameter must be a GET request,

But the URL: '/admin/sys/[email protected][' pid ',

When this sentence request method I see is a post submission, so I Baidu for a long time, finally clarified the GET request and POST request:
1. As long as the URL request, must be a GET request!

2. If it is a URL request, but it is a POST request, it is likely that the request is in some containers, such as the problem I encountered here is because the Easyui DataGrid itself is the default post request.

How to differentiate get requests from post requests

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.