E-Book, Englisch, 296 Seiten
Lair Beginning Silverlight 2
1. ed
ISBN: 978-1-4302-0570-8
Verlag: Apress
Format: PDF
Kopierschutz: 1 - PDF Watermark
From Novice to Professional
E-Book, Englisch, 296 Seiten
ISBN: 978-1-4302-0570-8
Verlag: Apress
Format: PDF
Kopierschutz: 1 - PDF Watermark
This book takes you on a guided tour of the new tools available to create Silverlight applications, from Expression Design and Expression Blend through to Visual Studio 2008. It explains how each of the tools performs it's part of the job of putting together well-constructed Silverlight applications and demonstrates this with a series of straight-forward examples that illustrate how developers and designers can perform their roles in harmony. By the end of the book, you will be well prepared to start creating Silverlight applications, both on your own or with the support of a design team.
Robert Lair is the president and chief executive officer of Intensity Software, Inc. and has been working with Microsoft .NET technologies since prior to its initial release in 2000. Among his accomplishments, Robert was on the team that created the original ASP.NET sample application IBuySpy, used to demonstrate the power of ASP.NET. Robert is an active speaker and writer in the development community.
Autoren/Hrsg.
Weitere Infos & Material
CHAPTER 6 Data Access and Networking (S. 117-118)
Data access in Silverlight applications works differently than it does in traditional applications. You’ll need to be aware of how it works and the limitations. In this chapter, we will look at what makes data access different, and then explore mechanisms for accessing data in a Silverlight application.
Data Access in Silverlight Applications
As discussed in Chapter 1, RIAs bridge the gap between Windows-based smart clients and web-based applications. When moving to this type of environment, data access and networking can be confusing. In a Windows-based smart client, the application has access to the database at all times. It can create a connection to the database, maintain state with the database, and remain connected.
On the other hand, a web application is what is known as a pseudo-conversational environment, which is, for the most part, a completely stateless and disconnected environment. When a client makes a request to the web server, the web server processes the request and returns a response to the client. After that response has been sent, the connection between the client and the server is disconnected, and the server moves on to the next client request. No connection or state is maintained between the two.
In Silverlight applications, we have one additional layer of complexity. The application runs from the client’s machine, however, it is still a disconnected environment, because it is hosted within a web browser. There is no concept of posting back for each request or creating a round-trip to the server for data processing. Therefore, data access is limited to a small number of options.
In addition, a Silverlight application has a number of security restrictions placed on it to protect the users from the application gaining too much control over their machine. For instance, the Silverlight application has access to only an isolated storage space to store its disconnected data. It has no access whatsoever to the client’s hard disk outside its “sandbox.” Silverlight’s isolated storage is discussed in more detail in Chapter 7.So what are your options for accessing data in a Silverlight application? The following main mechanisms are available:
• The most common mechanism to access data from a Silverlight application is through web services, typically a WCF service.
• Silverlight applications can access data using ADO.NET Data Services, which provides access to data through a URI syntax.
• Silverlight 2 also has built-in socket support, which allows applications to connect directly to a server through TCP sockets.
• Silverlight 2 has out-of-the-box support for JavaScript Object Notation (JSON), as well as RSS 2.0 and Atom 1.0 syndication feed formats.
Of these mechanisms, we’ll explore accessing WCF services from Silverlight 2 in depth, and then have a high-level look at using sockets. For examples and more information on accessing other data services, refer to Pro Silverlight 2 in C# 2008 by Matthew MacDonald (Apress, 2008).




