17.07.2015 Views

The Art of SQL Server FILESTREAM - Red Gate Software

The Art of SQL Server FILESTREAM - Red Gate Software

The Art of SQL Server FILESTREAM - Red Gate Software

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 5: <strong>FILESTREAM</strong> with ASP.NET and SilverlightAlternative to the Stream.CopyTo() method<strong>The</strong> copy <strong>of</strong> the stream content in this lab is done using the Stream.CopyTo() method, which wasintroduced with the .NET Framework Version 4. If your application targets an older Framework version,refer to the other code samples in this chapter for a way <strong>of</strong> copying the contents <strong>of</strong> one stream to anotherusing a 4 KB buffer (which is what Stream.CopyTo() also does).Creating an HTTP handler to serve images<strong>The</strong> concept <strong>of</strong> showing the web page in a web browser will be very similar to theone used in Lab 6, but the code will look different. <strong>The</strong>re will be no reference to any<strong>SQL</strong> types at all; any data access is completely abstracted in the data access layer (theDataAccess project).To drive this point home, in the Presentation web application, remove the reference tothe System.Data assembly. <strong>The</strong>n we will also modify the web.config file to includethe database connection string. Refer to Listing 5-3 for this code. In the final version <strong>of</strong>the application, this connection string can be removed. Because we are taking a stepby-stepapproach to this implementation, we will initially test the code whereby theweb application calls into the data access component directly, and the web application'sconfiguration file will provide the required connection string information.209

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!