Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML form send data by GET instead POST

Tags:

html

post

get

It is very strangely, but my HTML form send data via GET, not POST.

    <form name="mistake" action="http://web-server.com:8888/WebApp/Email/Create" method=post>
  <input type="text" name="url" size="50" readonly="readonly">
          <br />
          <span class="text">
          Error :
          </span>
          <br /> 
          <textarea rows="5" name="mis" cols="37" readonly="readonly"></textarea> 
          <br />
          <span class="text">
          Comment :
          </span>
          <br /> 
          <textarea rows="5" name="comment" cols="37"></textarea> 
          
          <input type="hidden" name="email" value="[email protected]">
          <input type="hidden" name="subject" value="Errors">
          <div style="margin-top: 7px"><input type="submit" value="Submit">
          <input onclick="hide()" type="button" value="Close" id="close" name="close"> 
          </div>
</form> 

I test it on IE10 with standart options.
HTML form very simple and i write only little example of code.
How to fix it?
Thank you!

P.S. Change URL. This URL web-server.com:8888/WebApp/Email/Create - belongs to asp mvc app.

When i run my web app and ths static site on local machine- it works. But when i runs static page on local machine- and mvc on server- it not works.

P.P.S.- this variant of form- is origine (i cut some tags). Now it is origine.

I dont why, but it works. May be - problem on server side?

like image 706
Admiral Land Avatar asked Jan 21 '14 11:01

Admiral Land


People also ask

Can an HTML form be submitted using GET instead of POST?

Forms in HTML can use either method by specifying method="POST" or method="GET" (default) in the <form> element. The method specified determines how form data is submitted to the server. When the method is GET, all form data is encoded into the URL, appended to the action URL as query string parameters.

Can I use GET instead of POST?

As with submitting any form data, you have the option of submitting your data in the form of GET requests, and you will save a few lines of code if you do so. However, there is a downside: some browsers may cache GET requests, whereas POST requests will never be cached.

Is it possible to send form data using a GET request?

The form-data can be sent as URL variables (with method="get" ) or as HTTP post transaction (with method="post" ). Notes on GET: Appends form-data into the URL in name/value pairs. The length of a URL is limited (about 3000 characters)

What happened when you send data from a HTML form with GET method?

The GET method is the method used by the browser to ask the server to send back a given resource: "Hey server, I want to get this resource." In this case, the browser sends an empty body. Because the body is empty, if a form is sent using this method the data sent to the server is appended to the URL.


3 Answers

A web application framework I am using automatically redirects POST requests for the action URL to the same URL with a trailing slash. HTTP redirection downgrades POST to GET.

like image 143
eel ghEEz Avatar answered Oct 09 '22 12:10

eel ghEEz


This post helped me fix what was causing the issue for me.

If IIS Manager redirects the url, it changes a POST request to a GET request. I had to change the server to re-write the url instead of redirect it.

I also had to enable Application Request Routing in IIS Manager. I followed the instructions in this post.

like image 45
Kade Avatar answered Oct 09 '22 13:10

Kade


The problem is rather common and the answer quite elusive:

Somewhere in your code you have an orphaned <form>. This means that the next form is nested in the previous one, and its method is ignored. Delete or close the superfluous <form> and you are done.

like image 23
Baron François Devant Avatar answered Oct 09 '22 14:10

Baron François Devant