I’ve been writing some code that will do a form post from one website to another. (php to an asp.net site)
I created the form that will post the values stored in a couple of hidden input tags. I used the id attribute to name each input tag.
I run a test and it looks like it posted succesfully to the asp.net site. All is good. Well….Maybe not. The asp.net site shows that it received a post but there are no items in the Forms or Querystring collection.
I don’t even think to look at then php code because A) the php page displayed in the browser and B) it did the submit to the other site without throwing a javascript error. I’m thinking the problem is 100% on the asp.net 2.0 site that received the post.
I spend the next 1.5 hours trying everything I could think of but I still can’t get the what should have been posted to the page to show up.
After almost throwing my computer out the window, I go back and look at the PHP code. I then decide to use the name attribute instead of id. Guess what? It worked!
So some of you maybe wondering why I was using id attribute instead of name? It’s because I’ve gotten so used to using the id attribute for asp.net server controls that I’d almost forgotten about the name attribute!
So the moral of the story is to write plain html once in a while so you don’t make these kind of rookie mistakes! It’s always something so simple that can ruin a good day of coding!
2 comments ↓
This is where the Live HTTP Headers plugin (firefox) and/or Fiddler could’ve helped too.
Peek under the hood.
Thanks for the tip. I will have to take a look at that!
Leave a Comment