Admiral Land
Admiral Land

Reputation: 2492

HTML form send data by GET instead POST

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?

Upvotes: 11

Views: 28251

Answers (8)

sachinsaini
sachinsaini

Reputation: 73

(In my case, I found some causes.)

There can be many causes two of them are:

  1. If forget to close the form tag.

  2. Written post in a wrong way. i.e. It should be something like this:

    <form action="index.php" method="post">

If you write method=post , method ="POST"or method ="Post" then it will not work. Hope it will solve your problem.

Upvotes: 1

Kade
Kade

Reputation: 1022

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.

Upvotes: 1

eel ghEEz
eel ghEEz

Reputation: 1225

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.

Upvotes: 5

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.

Upvotes: 25

Sam Adams
Sam Adams

Reputation: 25

I did have the same problem once here what i did: the problem first come when a form is nested inside another one, and its method is ignored.

the solution is pretty simple: Delete or close the superfluous and you're good to go .

Upvotes: 1

acarlon
acarlon

Reputation: 17272

It should be a post (assuming that you forgot the closing tag only in your example). I added your code and put the closing tag in an html file and submitted in Chrome. This is what I see in the network trace:

enter image description here

Also look at this question in case you are doing the same.

Upvotes: 5

Rushyo
Rushyo

Reputation: 7604

May simply be that your user-agent is ignoring the form method because you haven't put quotes around the attribute.

Try:

 <form name="mistake" action="http://web-server:8888/WebApp/Email/Create" method="post">

Upvotes: 0

Jez D
Jez D

Reputation: 1489

Try method="post" instead of method=post

Upvotes: 0

Related Questions