Wednesday, February 15, 2006

Never ever forget the ContentType header when using POST

I have been working on this project that involves sending content from the client to a web server. Actually there are two different projects which were hung up because of one simple ContentType header. Here is the line of code that I was missing out which was causing so much problems for the past few days.
m_WebRequest.ContentType = "application/x-www-form-urlencoded"

I had to document it or else I would forget it as time passes by. This is a VB.net project but the same mistake can cause problems in an AJAX scenario when you are trying to post data. If for some wierd reason you feel that your post data is giving you trouble while it works fine in the web browser set the ContentType header.
Technorati Tags: , ,

No comments: