ASP.NET Web Pages – Setup

[ This is a 4 part tutorial ]

Dynamic websites allow us to use a database to store our content. In the next 4 tutorials we will learn the CRUD functions for ASP.NET Web Pages. It is very simple to perform CRUD operations; with some knowledge of C# and SQL you should be able to pick this up instantly.

Setup

  1. Create a new website based of the StarterSite template, and name the website CRUD.
  2. In the root directory create the following files: Create, Update, Read, Delete, and _PageStart (CSHTML files).

In the _PageStart file replace the code with the following:

@{
 Layout="~/_SiteLayout.cshtml";
}

Next, open the _SiteLayout.cshtml file and add this below the <title> tag:

<meta name="description" content="@Page.mDescription"/>

Install WebPageRouteHandler.cs

  1. Click Nuget
  2. Type “Routing for WebPages”
  3. Install the RouteHandler

WebPages RouterHandler Installation

In the _AppStart file we want to add a new route. At the top of the file we first need to add the namespace routing:

@using System.Web.Routing

Then in the code blocks insert the route pattern:

RouteTable.Routes.MapWebPageRoute("games/{GameName}", "~/Read.cshtml");

Lastly, go to the CKEditor website http://ckeditor.com/download and download the standard package, extract it and move the CKEditor folder to our website (root directory).

Now we are done with the setup, so let’s start to create dynamic pages! [Continue, Insert Data Page]