Doing a simple timeout page with WebClientApplication

<%@ Application Language="C#" Inherits="Microsoft.Practices.CompositeWeb.WebClientApplication" %>
<script Language="C#" RunAt="Server">

protected override void PrePageExecute(Page page)
{
// True when the current session was recreated with the current request
if (Session.IsNewSession)
{
// redirect if the requested page is not Default or the Timeout page
// or if the request method isn't GET
if ((!(page is Retail.Web._Default) &&
!(page is Retail.Web.Errors.Timeout)) ||
Request.HttpMethod != "GET")
{
Response.Redirect("~/Errors/Timeout.aspx");
return;
}
}
base.PrePageExecute(page);
}
 



This approach relies on the Session.IsNewSession property to tell us if the current session was created with the current request, with a bit of convenience support for the timeout/default pages.


Nikhil has a more detailed solution: Detecting Session Timeout in ASP.NET 2.0 Web Applications if you want to differentiate between



  • new session object and user was really new, (aka no ASP.NET_SessionId)

vs



  • new session object and the user really timed out (aka sorry I was surfing the web and the app timed out)

Nikhil Kothari's behaviour framework for SilverLight

Nikhil here describes a mini behaviour framework for SilverLight, and then proceed to implement a DefaultCommit, AutoComplete and TextFilter behaviours that can be attached to the SilverLight textbox.

Very cool.

http://www.nikhilk.net/Silverlight-Behaviors.aspx

http://www.nikhilk.net/Silverlight-AutoComplete.aspx

Two more SilverLight links

http://silverlight.net/forums/t/3015.aspx

A comparison of SilverLight 1.0 vs Flex/Flash

Some of the SilverLight limitations no longer apply in SilverLight 2.0 beta.

  • Linux support is handled by Moonlight - sponsored by Microsoft via Novell
  • SilverLight has data binding support
  • SilverLight has control library
  • SilverLight control library shipped with full testing tools - I assume these can be modified to do SilverLight unit testing
  • Socket programming is possible now
  • SilverLight has building download support.  Not sure about what upload support means, pushing a data into a web service?
  • Disagree with performance being slower - I would argue that both system would run equally fast.  There's no reason one should be slower than the other.
  • SilverLight is deployed in one XAP file.  The XAML is included so that it can be indexed.

The next link is a RIA test web site.

http://www.bubblemark.com/

On my machine (FireFox):

  • DHTML: 60 fps
  • Flex: 63 fps
  • Flex (cached): 63 fps
  • Java (Swing): 63 fps
  • SilverLight (JavaScript): 56 fps
  • SilverLight (CLR): a whooping 330 fps

You should free up some memory for your browser for the HTML/JavaScript tests - restarting the browser usually does the job.  If you already have 10 tabs open the DHTML/JavaScript ones won't run as well.

Seriously, you got to see this to believe it.

Removing a word from Windows Live Writer user dictionary

So I screwed up.  In my zeal to make sure my blogs are fully spell-checked, I added a misspelt word to my Windows Live Writer user dictionary.

There are no easy way (at least, as far as I could tell) to remove it.  I ended up doing the following:

Open in notepad:

%APPDATA%\Windows Live Writer\Dictionaries\userdic.tlx

Fix the spelling, save the text file back.

Restart Windows Live Writer

I hope this helps someone out there.

SilverLight is better than AJAX + DOM

I just got home from the Sydney .NET User Group tonight, where they talked about SilverLight and Flex in a session focused on RIA.

I personally think the session was relatively informative to a general crowd,  but not detailed enough to go into the specifics.  I'm not sure what the intended audience was given that the SNUG crowd is pretty much all .NET guys.

I had a chat with a few guys after the session and most were unsure or even unimpressed with what SilverLight has to offer.

I find that pretty sad.

The main arguments against SilverLight were along the lines of:

  • All those can be done with AJAX

Perhaps the presentation was too general and did not focus on outlining the benefits of using SilverLight over plain old AJAX.

I think there is a very naive view of SilverLight among the audience tonight.  Probably, what we needed to convince the .NET people that SilverLight is cool is this following list of stuff that just can't be done with AJAX.

Development Scenarios

  • Dynamic loading could be done with AJAX, but you have to test it with FireFox, IE6/7/8, Opera, Safari.
    Not to mention the various combinations of operating Systems with them.
  • Did I mention mobile devices?
  • Difficult debugging scenarios - VS.NET actually makes this easier for IE and FireBug made it easier for FireFox, but essentially you are down to debugging JavaScript, which is iffy at best.
  • Mucking around with CSS and DOM is wasted time
  • SilverLight can be debugged directly in VS.NET - there is an option to switch on (default)

Vector Graphics

  • No vector graphics with the DOM
  • Try to do rounded corners with DOM and you either have to resort to some background picture trick (lots of files and connections) or stuff around with multiple layers of borders (nasty looking DOM).
  • You can't even draw a diagonal line in the DOM,
  • Let along trying to do Ink (point below)
  • There is a reason that people wanted SVG support, and to pass the ACID3 test the browser needs to natively implement SVG, and Microsoft is criticized heavily with not supporting SVG out of the box in IE8 (they probably never will).
  • People know the DOM sucked at this stuff, they wanted to stick SVG in the browser so they can stay mucking around with the DOM some more.
  • To be fair, Adobe was at the forefront of SVG development, but as soon as they picked up Flash/Flex/Macromedia, they stopped their free SVG plug-in development immediately.
  • I think SVG is a waste of time in the wrong direction altogether.  SVG was designed for a market that failed to materialize in 1999.  The reason that Flex and SilverLight are successful is because people and technology have moved on.
  • I'm convinced a SilverLight vs Flex scenario is better for the world as both companies race forward to win developer minds.
  • Finally, if you are not convinced SVG is dead, go to Yahoo! Finance's interactive chart here and tell me how much stuffing around would it be required to get those cool looking graphs to work with DOM+SVG+AJAX.

Animation

  • The SilverLight story boards is a time-based system, which is an improvement over the frame based systems in Flash. 
  • I think with SVG another protocol SMIL will be needed to achieve the same thing.

Ink

  • SilverLight supports Ink

Layout Management

  • Stop stuffing around with aligning this label/textbox with another label/textbox halfway down the screen, past the grid in between
  • The DOM simply don't support proper layout management, and hacking it via CSS is ugly, or fails to scale when the browser window size changes
  • Which is a big problem for mobile devices, apparently.

Data Binding

  • SilverLight has data binding support out of the box.  Browsers/DOM/AJAX are stuck with manual data binding, or part/full page post backs.

Framework

  • SilverLight is build with a solid set of the .NET framework library.  This includes multiple out of the box functionality that would need to be build with JavaScript
  • Working with proper collections and generics, or LINQ and LINQ to XML

Threading Support

  • Bread and butter of Windows Application development.  Threading has never worked properly, if at all with AJAX.
  • Try calling three web services at once and collect their responses and make some use of them.  Note that any or all of these asynchronous calls can and will fail.  Most DOM/AJAX implementations of the XMLHttpRequest stuffs up right about here.

Isolated Storage

  • Isolated Storage
  • AJAX systems rely on ViewState or server session systems.  ViewState is passed around all the time and takes up bandwidth, and is lost when user logs off. 
  • Cookie file is far limited in size.

Network Capabilities

  • Sockets
  • Cross-Domain calls - excluding JSON with AJAX.

Serialization

  • JSON, XML, SOAP Serialization

File Processing / Upload

  • The HTML upload input control is still stuck at the 90s
  • SilverLight has read-only access and has OpenFileDialog implementation
  • Can preview a file on client side before deciding to make service call to upload them.  Doesn't even need to upload them.

 

Argh I'm tired.  That's probably too much info for one evening.