Categories
Silverlight 2: trouble with POST requests
23rd November 2008
I am trying to make a small Silverlight control that talks to PHP server. Sometimes problems arise and I have to deal with them myself, since there’s not much information on this topic in the internet. Trouble of the day is:
The remote server returned an error: NotFound
when trying to make simple POST request to a PHP page. I’ve spent half a day diagnosing this problem. And solution was found entirely by chance, because exception messages weren’t helping in any way. I mean, I was always getting abovementioned error message, without any details (what host, what page, request parameters, etc). But enough of complaints, let’s proceed to the solution. The troublesome code was this one:
var _request = (HttpWebRequest)WebRequest.Create(_svcUri); _request.Method = "POST"; _request.ContentType = "application/json"; _request.Headers["sid"] = SessionID ; // <==== this line
SessionID was null at the moment and this made HttpWebRequest so pissed off that it even wouldn’t send request header to the server ! And because of this, Fiddler was completely useless here. After adding necessary check, everything started working like a charm.
View Comments
RSS feed for comments on this post. TrackBack URL
Sorry, the comment form is closed at this time.
[...] the original here: Silverlight 2: trouble with POST requests Related ArticlesBookmarksTags Test @ 4:05pm post changes to php **Note my email address [...]
Pingback by Silverlight 2: trouble with POST requests | PHP-Blog.com — November 23, 2008 @ 11:00 PM