What is the default form HTTP method?
As stated in the link above an everywhere else the default posting method used in HTML forms is GET but I seem to get the POST methods results when NOT including the method=”” attribute in my form declaration:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Ny test</title>
<link rel="stylesheet" type="text/css" href="StyleSheet.css" />
</head>
<body>
<form action="Default.aspx" runat="server">
Name: <input type="text" id="navn" runat="server"/>
<input type="submit" id="submit" value="Submit!" runat="server" />
<input type="reset" />
<br />
</form>
</body>
</html>
The HTML code above results in the following output in the URL after the submit button is clicked:
When explicitly using the “GET” method attribute I get the following output in the URL after the submit button is clicked:
Why is this happening? Default posting method for HTML forms is GET, so why I am getting the opposite results when not including GET as the method attribute?
Is this Visual Studio/ASP.NET defaulting to the POST method in HTML forms?
ASP.Net sets the
methodtoPOSTfor the form. I assume so that button presses result inPOSTrequests which is more semantic than aGETand to prevent very long urls with the viewdata in the querystring.Check your HTML source and you will see the
method="post"attribute.