Title: Offline Detection in SL3 and .NET Framework (T78m, video)

Presenter: Peter Smith, PM, .NET Networking Group, pesmith@microsoft.com

  • Session is 18:11 in duration
  • Session PPT has additional slides of interest
  • Why offline detection?
    • SL3 has the ability to run “out of browser” on the user’s desktop, just like a normal application
    • Sometimes when your code runs, the user will NOT be online
    • You have to detect and handle this case
  • The One Take-Away Point (1:55)
    • The only way to know 100% that you’re online is to retrieve a known file from your server and validate the content
    • Due to the “coffee shop problem” (named later), you might not have internet access, even using the following clues:
      • A web response has a status 200
      • A web response can have valid HTML returned, which is the coffee shop screen asking for a passcode for internet access
    • SL3 API provides some assistance with network change event, but that alone is not enough
  • Demo, 2:39
    • App has visual indication of offline/online
    • Plugs a network cable into router, that does NOT have internet access
    • App thinks it’s online
  • Why offline is so hard, 3:44
    • Is the network useful?
    • Driver issues
    • Virtual PC’s
      • virtual card says your online because the host is the connection
    • Coffee Shop problem
    • Maybe you shouldn’t connect
      • For situations where the user does gets charged for transmissions by the Kb
  • VB.NET and C# Sample
    • Creates handler and registers for NetworkInformation.NetworkChange.NetworkAddressChanged
  • Patterns for your Code (10:05)
    • The ABC of Network detection
      • Ask the user
      • Before you connect, validate
      • Constantly validate results
    • Consider doing #1 and either #2 or #3
  • Ask The User (11:23)
  • Before you connect,validate (12:10)
    • Personally likes using an XML file, checking for a known section, and using for multiple SL app’s
    • Revalidate on network change
  • Constantly Check Results, 14:11
    • Start in online mode
    • Validate every single request
  • NCL (System.Net) blog is http://blogs.msdn.com/ncl
  • Team forum is http://social.msdn.microsoft.com/Forums/en-US/ncl/threads