This is a mirror of official site: http://jasper-net.blogspot.com/

Silverlight Session Management, Error handling, and Unit Test of WCF service

| Thursday, September 16, 2010
Acknowledgement

I had the following requirements:

Session management.
In the second web service call, i want to know something from the first call

Impersonate user
I don't want to enter my credentials if my service has to work as my user.

Error handling
it’s not very cool to get a white website after an error occurs.

Unit tests of the wcf service
It would be great to have tests for the stuff above

Let's start. I'm going to implement each of these topics separately, and hopefully get a solution working till this blog entry is finish. You can download attached ZIP file which contain the solutions above requirements.

Introduction

I just start with a new Silverlight solution in visual studio 2008. The only thing I change from original, is to assign a static port to the built in web server. This makes the life with WCF much easier. Then add a new Silverlight-enabled WCF Service to the web project, create some operation contract, and add a service reference to the silverlight project.

Using the code

1. Session management (with aspNetCompatibilityEnabled)

For this, there are two possibilities:

1. Do it yourself (Write something like a session agent service)
2. Use the ASP session management

I guess there are lots of reasons not to use aspNetCompatibility (The most obvious might be performance), but the simplicity of it was the reason for me to choose it anyway. I have to say that I did not invent this, I just copied it from an article of SpoonStomper from the silverlight forum.

The following goal I want to achieve. I press a button on my silverlight application which sends a string to my service. Then I want to press another button and get back this string again(Sounds really easy btw.).

Read more: Codeproject

Posted via email from .NET Info

0 comments: