Skip to main content

Posts

Showing posts with the label Silverlight

What i learned today.

Working with ASP.Net and SilverLight in my current project i learned two important things today SL will always show generic NotFound exception for a remote call failures irrespective of what was returned from server. This limitation roots in the browser which does not pass the exception details to the SL plugin. The only way around is to always send a responses which have Fault property for the SL client to work with. ASP.Net forms authentication mechanism always redirects on 404 error and behaviour is hard to change. This becomes a problem working with SL or ASP.Net MVC clients which expect Http error code (REST clients). The workaround that i found on Stackoverflow was to thrown 403 Error Code instead of 401. This way service calls made from SL or ASP.Net MVC can return http status codes (REST endpoints) and will not cause server redirects.

Encoding\Escaping special characters in Silverlight

I spend almost half an hour to find how to do encoding\escaping special characters in SL. Started with SecurityElement to HttpUtility etc but none were available in SL. Well as it is with google, if you ask correctly you would be rewarded. Turns out that there is a class in System.Windows.Browser assembly for SL that contains HttpUtility class. Checkout here If i had just type HttpUtility in the IDE i could have got it :( Anyhow, Happy Coding.