A working wiki

ASP.NET is a key component of the .NET Framework, which enables you to develop rich, complex websites. ASP.NET is both a programming framework and a runtime environment, and so sites get built upon and exploit the functions in the Common Language Runtime. ASP.NET is also used on servers at runtime, to enable IIS (Internet Information Server) both to serve up the pages and to implement XML Web Services (which I described in last month’s column).

A working wiki

In an ASP.NET web application, files containing pages take the extension ASPX (for example, Microsoft’s homepage is www.microsoft.com), and such pages may contain both the UI (the HTML that gets rendered in your browser) and the code that implements some or part of the page’s functionality. It’s best practice for the code to be separated out into a “code-behind” page, with the extension CS (as in default.aspx.cs) for C# code or VB (as in default.aspx.vb) for VB.NET code. The code-behind file specific to any given ASPX file is identified in the latter through the use of the CodeFile attribute in the Page directive.

The screenshot (above right) shows a simple web page being edited in Expression Web Designer that provides a trivial add/subtract calculator; the ASPX page lays out a few controls on the page and then calls out to a separate code-behind file to perform the necessary calculations. In the page directive, the code-behind file is identified as a C# file by its name calc.aspx.cs, and this code is shown in the box overleaf. To deploy the application, you just copy the two files (ASPX and CS) to the website root folder on your local machine – by default, IIS sets this up to be C:Inetpubwwwroot – then navigate to http://localhost/calc.aspx in your browser, enter two numbers into the textboxes provided and click a button, as shown in the screenshot below. Your browser sends a request to IIS, noting that a button has been pushed and providing the values you entered. IIS then calls the code-behind, invoking the appropriate method. The code-behind method updates the contents of Label1 with the calculated result, and then IIS returns the page to you, complete with answer.

FlexWiki

The calculator example is very simplistic, designed to show only the basics of ASP.NET, and I needed a more complex example to show off the more advanced features. Rather than write lots of code myself, I’ve chosen a free ASP.NET application called FlexWiki, but before looking at that let’s clarify what a Wiki is and how it works. A Wiki is a website whose content can easily be edited by its users using nothing more than a web browser. The term was coined in 1994 by Ward Cunningham to refer both to his website WikiWikiWeb (c2.com) and to the engine that drives it.

The best-known wiki today is Wikipedia (www.wikipedia.org), a free online encyclopedia that anyone can contribute to and edit – it’s being written collaboratively, with thousands of changes per hour. This might sound like an invitation to vandalism, but while Wikipedia has certainly had some nasty incidents, each change gets recorded so that any deemed inappropriate can be removed and older content restored. Wikipedia can also block repeat offenders from further editing – a sanction they’ve had to apply in a few cases.

You add content to a wiki via your web browser, using its software engine and a simple markup language that lets you add bold/italic formatting, headings, tables and images, as well as external references. Most wikis also provide some way to create dynamic content, for example, by scanning all the pages in your wiki and accumulating a list of pages that meet some criterion, such as containing a specific tag.

Disclaimer: Some pages on this site may include an affiliate link. This does not effect our editorial in any way.

Todays Highlights
How to See Google Search History
how to download photos from google photos