Introducing ASP.NET Web Pages

ASP.NET Web Pages is the latest addition to the ASP.NET platform and provides a web development framework for new developers who want to build simple websites using ASP.NET.

Although ASP.NET Web Pages provides a simple framework, it leverages on the .NET Class libraries, enabling developers to create simple yet powerful web apps. The configuration steps involved are fewer in comparison to WebForms or ASP.NET MVC. ASP.NET Web Pages are developed using the new light Razor syntax which allows you to mix markup (HTML)  with server side programming logic. The good ol’ classic ASP days eh!

Here’s how ASP.NET Web Pages fits into the ASP.NET Technology Programming Model

aspnet-webpages-framework

ASP.NET Web Pages are created using WebMatrix. If you are new to WebMatrix, check out my article Introducing WebMatrix

Creating your first ASP.NET Web Application using WebMatrix

Assuming you have WebMatrix installed, start WebMatrix and click the ‘Site From Template’ option. Choose ‘Empty Site’, give it a name and click OK.

site-from-template

From the WebMatrix Environment, click ‘Files’ in the lower right corner and click on Create a New File.

web-matrix-environment

In the next screen that appears, choose a file type.We are going ahead with CSTHML, which is an ASP.NET Web Page using C#.

create-aspnet-webpage

Click OK.

Add the following code in the <body> tag

razor-code

Observe the @sign. This is the Razor syntax we are using. Hit Ctrl+S and run the application (F12) and you should see the following.
image
Congratulations! That was your first web application using ASP.NET Web Pages and WebMatrix.

Difference between WebForms and ASP.NET Web Pages

ASP.NET comes in 3 flavors – ASP.NET WebForms, ASP.NET MVC and the newly introduced ASP.NET Web Pages. While ASP.NET WebForms and MVC are designed for the enterprise developers, ASP.NET Web Pages makes it easy for new developers to get started with ASP.NET.

The official ASP.NET site lists down a difference between the three:

webpages-vs-webforms





About The Author

Suprotim Agarwal
Suprotim Agarwal, Developer Technologies MVP (Microsoft Most Valuable Professional) is the founder and contributor for DevCurry, DotNetCurry and SQLServerCurry. He is the Chief Editor of a Developer Magazine called DNC Magazine. He has also authored two Books - 51 Recipes using jQuery with ASP.NET Controls. and The Absolutely Awesome jQuery CookBook.

Follow him on twitter @suprotimagarwal.

No comments: