How to Build Sites Using Web Pages and VB

WebMatrix includes many templates that make it easier for you to get started with ASP.NET Web Pages. Today, WebMatrix ships with templates that use the the Razor format with C# syntax. However, if VB is your preferred language, you can also get the same templates in VB from the NuGet gallery.

 

Creating a site from template

To get started, click the Templates icon on the WebMatrix start screen:

WebPagesVB-1

 

If it’s not already selected, click the ASP.NET templates section. Choose the Empty Site template, give your site a name, and click Next:

WebPagesVB-2

 

The site is created and can be run immediately. However, the source code for the site uses C# style Razor syntax. To use VB instead, first switch to the files workspace. Then, click the NuGet Gallery icon in the ribbon:

WebPagesVB-3

 

In the NuGet Gallery dialog, switch to the All category. Use the the search box to search for the template that you want to use with VB. The following example uses the Bakery template. Follow the steps in the dialog to install the template.

37314nuget

After the template is downloaded, you'll need to copy its files to the root of your site. Open the Microsoft Templates directory, and then the BakeryVB directory (or the directory name for your template). Select all of the files in the BakeryVB directory by first clicking the App_Data directory, holding down the shift key, then clicking the OrderSucess.vbhtml file.

WebPagesVB-5

 

Next, drag the selected files into the root of your site. Delete Default.cshtml, making sure that Default.vbhtml is present. Delete the Microsoft Templates folder. Your directory structure should now look like this:

WebPagesVB-6

In the ribbon, click the Run button, and your site will be up and running with ASP.NET Web Pages and Visual Basic.

You can discuss this article using the adjacent Facebook talkback.

For technical questions please visit our discussion forums, where we have a vibrant community of developers like you, as well as Microsoft engineers who are ready to answer your questions!