Categories
Silverlight: Security Error
24th November 2008
Sometimes, you may get not-very-descriptive System.Security.SecurityException. Stack trace tells you that something bad happened somewhere inside EndGetResponse, and that’s it, no more details. One possible cause is this: in a Silverlight project you may tell it to generate a temporary page that will host your application.
And if your application sends requests to some host (a linux virtual box, in my case), this will be the source of pain. The dynamically generated page gets loaded to Internet Explorer as file://your_path/TestPage.html. And you are trying to reach HTTP(S) host. This cross-scheme behavior is not allowed.
For more information, see this MSDN article and this forum thread.
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.