Improve the performance of your ASP.NET application with Silverlight 2.0

Monday, December 15 2008

Silverlight 2.0 Release just came out and developers are creating great flashy websites using this great plug-in technology. Yet there isn’t much about how Silverlight would provide a architecture to improve performance by using the clients CPU instead of the server running ASP.NET.

The great communication between Silverlight and JavaScript will give developers a way to provide “compiled JavaScript” objects that would run on the clients CPU instead of the servers hosting the web application. In previous post I gave a few samples of the communication between Silverlight 2.0 and JavaScript using the ScriptableMember attribute.

There are many improvements that you can make using Silverlight to improve the performance and user load of your web server.

Isolated Storage

Instead of keeping the Session State on the web server, it can be pushed to the Silverlight client and stored on the hard disk using.

The biggest problem on web application were that you didn’t had access to the local hard disk to store  information. Now Silverlight 2.0

More info about Isolated Storage.

IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication();

I created a Silverlight class called SilverlightSession that stores all the session state with the reference to the ASP.NET Session ID. Silverlight only sends the encrypted information need it per method to the server, so the web server is on to know basis instead of having to store every bit of information from every user.

Web Services.

Instead of creating a web services endpoints for your Ajax to call, you can instead just call Silverlight methods to do the processing. There is a great sample of that by Michael Schwarz about how to encrypt AJAX communication.

Those Silverlight Methods can include processing that might take a long time to run in JavaScript or mathematical calculations. If you revise your ASP.NET application, you will encounter many Web Forms that can be moved to Silverlight. Another examples of that is anything that parsers, like an XML parser.

Security by User Roles.

ASP.NET provides you with a role based security so the user role will restrict what the user can do. I am in the process to move those rules into a Silverlight xap that will be download it for the javascript to restrict what the user can see without having to render the page and go through the page cycles. The role based security rules will be compiled into Silverlight that will callback javascript to make those div visibility change depending of that user role. I’ll provide all source code as always shortly.

Cheap SSL or better SSL?

For years the most secured communication for a browser was to use the 443 port with a SSL 126 bits encryption key. Now, thanks to Silverlight you can provide that same encryption between the client and the server without installing SSL certificates or paying a third party provider like Verisign for that capability. All communication between the client and the server does not need to use the POST can be called to a Silverlight method for 128 bits encryption and be sent to the server. I have already seen profs of developers wanting that control in their hands for a faster communication as well as avoiding the nightmare of the browser alerting you about unsecured items you didn’t want inside the SSL page. Would take time until users trust the Silverlight encryption without displaying the yellow lock in the browser or waiting the long latency of the SSL post.

Multiple file upload.

Finally I would like to shine a light at this great post http://www.codeplex.com/SLFileUpload about going beyond the one file at the time restriction on the browser, now with Silverlight 2.0 you can process and send multiple files to the server using Silverlight 2.0.

I hope this post will give you a few ideas on your own to move the performance hog from your web server and push them to your client’s CPU to improves your website speed. You do not need to provide in the silverlight object a front end, just the C# classes to process users requests.

Let me know how it goes

Cheers

Al

PS Follow me at Twitter and send me your ideas

Posted from http://weblogs.asp.net/albertpascual

Comments

process server | AMD.com hot tags said on 12.16.2008 at 7:10 PM

Pingback from  process server | AMD.com hot tags


file server | AMD.com hot tags said on 12.17.2008 at 3:53 AM

Pingback from  file server | AMD.com hot tags


Community Blogs said on 12.26.2008 at 3:49 AM

You have been using Silverlight for a while and by now you figure it out that to communicate outside