Free beta ebook and samples : ASP.NET Web Pages with Razor Syntax

ASP.NET Web Pages with Razor Syntax is a web framework and part of WebMatrix which gives you everything you need to build Web sites using Windows.

A free  ebook (it’s a draft) and the samples are availables on the Microsoft Download Center.

Here is the table of contents :

Chapter 1 – Getting Started with WebMatrix Beta and ASPNET Web Pages 1

What is WebMatrix Beta? 1
Installing WebMatrix Beta 1
Getting Started with WebMatrix Beta 2
Creating a Web Page 4
Installing Helpers with Package Manager 7
Using ASPNET Web Pages Code 9
Programming ASPNET Razor Pages in Visual Studio 12
Creating and Testing ASPNET Pages Using Your Own Text Editor 13

Chapter 2 – Introduction to ASPNET Web Programming Using the Razor Syntax 15

The Top 8 Programming Tips 15
HTML Encoding 16
HTTP GET and POST Methods and the IsPost Property 21
A Simple Code Example 22
Basic Programming Concepts 24
Classes and Instances 25
Language and Syntax 26
Additional Resources 47

Chapter 3 – Creating a Consistent Look 48

Creating Reusable Blocks of Content 48
Creating a Consistent Look Using Layout Pages 51
Designing Layout Pages That Have Multiple Content Sections 55
Making Content Sections Optional 58
Passing Data to Layout Pages 59
Creating and Using a Basic Helper 65

Chapter 4 – Working with Forms 67

Creating a Simple HTML Form 67
Reading User Input From the Form 68
HTML Encoding for Appearance and Security 70
Validating User Input 71
Restoring Form Values After Postbacks 73
Additional Resources 74

Chapter 5 – Working with Data 75

Introduction to Databases 75
Relational Databases 76
Creating a Database 76
Adding Data to the Database 78
Displaying Data from a Database 79
Structured Query Language (SQL) 81
Inserting Data in a Database 82
Updating Data in a Database 86
Deleting Data in a Database 91
Connecting to a Database 95
Additional Resources 96

Chapter 6: Displaying Data in a Grid 97

The WebGrid Helper 97
Displaying Data Using the WebGrid Helper 97
Specifying and Formatting Columns to Display 99
Styling the Grid as a Whole 102
Paging Through Data 103

Chapter 7 – Displaying Data in a Chart 106

The Chart Helper 106
Chart Elements 107
Creating a Chart from Data 108
“Using” Statements and Fully Qualified Names 114
Displaying Charts Inside a Web Page 115
Styling a Chart 116
Saving a Chart 117
Additional Resources 123

Chapter 8 – Working with Files 124

Creating a Text File and Writing Data to It 124
Appending Data to an Existing File 127
Reading and Displaying Data from a File 128
Displaying Data from a Microsoft Excel Comma-Delimited File 131
Deleting Files 131
Letting Users Upload a File 133
Letting Users Upload Multiple Files 136
Additional Resources 138

Chapter 9 – Working with Images 139

Adding an Image to a Web Page Dynamically 139
Uploading an Image 142
About GUIDs 144
Resizing an Image 144
Rotating and Flipping an Image 147
Adding a Watermark to an Image 148
Using an Image As a Watermark 149

Chapter 10 – Working with Video 152

Choosing a Video Player 152
MIME Types 153
Playing Flash (swf) Videos 153
Playing MediaPlayer (wmv) Videos 156
Playing Silverlight Videos 158
Additional Resources 159

Chapter 11 – Adding Email to Your Website 160

Sending Email Messages from Your Website 160
Sending a File Using Email 164
Additional Resources 166

Chapter 12 – Adding Search to Your Website 167

Searching from Your Website 167
Additional Resources 170

Chapter 13 – Adding Social Networking to Your Web Site 171

Linking Your Website on Social Networking Sites 171
Adding a Twitter Feed 172
Rendering a Gravatar Image 174
Displaying an Xbox Gamer Card 175
Displaying a Facebook “Like” Button 176

Chapter 14 – Analyzing Traffic 179

Tracking Visitor Information (Analytics) 179

Chapter 15 – Caching to Improve the Performance of Your Website 183

Caching to Improve Website Responsiveness 183

Chapter 16 – Adding Security and Membership 186

Introduction to Website Membership 186
Creating a Website That Has Registration and Login Pages 187
Creating a Members-Only Page 191
Creating Security for Groups of Users (Roles) 192
Creating a Password-Change Page 194
Letting Users Generate a New Password 196
Preventing Automated Programs from Joining Your Website 200

Chapter 17 – Introduction to Debugging 203

Using the ServerInfo Helper to Display Server Information 203
Embedding Output Expressions to Display Page Values 205
Using the ObjectInfo Helper to Display Object Values 209
Using Debugging Tools 210
Additional Resources 213

Chapter 18 – Customizing Site-Wide Behavior 214

Adding Website Startup Code 214
Running Code Before and After Files in a Folder 218
Creating More Readable and Searchable URLs 224

Appendix – ASPNET Quick API Reference 227

Classes 227
Data 233
Helpers 234

Appendix – ASPNET Web Pages Visual Basic 241

The Top 8 Programming Tips 241
HTML Encoding 242
A Simple Code Example 248
Visual Basic Language and Syntax 250
Additional Resources 271

Appendix – Programming ASPNET Web Pages in Visual Studio 272

Why Use Visual Studio? 272
Installing the ASPNET Razor Tools 272
Using the ASPNET Razor Tools for Visual Studio 273

Disclaimer 278

Previous versions of the draft are also available.

For the latest informations and more about webmatrix and the Razor syntax, visit

Incoming search terms:

  • ebook razor database
  • razor syntax ebook