Before delving into the construction of the system, let us
enumerate the key techniques leveraged in this blog system.
·
A simple two-tier architecture
·
ASP.NET 2.0/3.5 components, such as GridView, FormView, DataList,
SQLDataSource, Master Page, SiteMapPath
·
The main ASP.NET AJAX server-side controls, such as
ScriptManager, UpdatePanel
·
ASP.NET AJAX Control Toolkit controls, such as CalendarExtender,
ModalPopupExtender, NoBot, PasswordStrength, PopupControlExtender,
TextboxWatermarkExtender, ToggleButtonExtender
·
URL rewrite technique
Altogether, during the course of authoring the mini blog
sample website, I tried to leverage ASP.NET 2.0 controls. As for the AJAX technique, it is probably well-known that the ASP.NET AJAX server-centric programming
is mainly centering on the ScriptManager and UpdatePanel controls. ScriptManager
serves as the control center of the client side while UpdatePanel is used to
achieve the partial update of a web page in the asynchronous way. What is more,
as for ASP.NET AJAX Control Toolkit, it is a set of ASP.NET server components
and controls which help to extend the functionalities of the original ASP.NET
server counterparts. Joyfully, most of the extenders are pretty easy to use—even with no coding. On the other hand, due
to the features of our sample applications, only a small number of the
extenders were put into use.
Concerning the URL rewriting (also redirection) technique,
it is a long story. So I will only say a few words about it.
URL rewriting is a most powerful technique available to
control the URL presented to the user, as well as to maintain websites'
permalinks. It is very important to most website content owners that their
links remain permanent, hence "permalink." As a protocol, HTTP
provides two ways to alert the browser: the first is a temporary redirect, or
302, and the second is a permanent redirect, or 301.
In ASP.NET v2.0, a new URL mapping technique comes into
being to simplify the URL rewriting programming by introducing a new
urlMappings configuration element into file web.config. Therefore, what you
need to do is add a new entry to web.config to achieve the aim of redirecting a
url. The following gives a simple sample for mapping a URL.
Listing 8
<urlMappings enabled="true">
<add url="~/Articles/AspDotNet/UrlRewriting"
mappedUrl="~/Articles.aspx?cat=1&id=16" />
</urlMappings>
The url attribute is what the user sees and the mappedUrl
attribute describes the actual requested page. In the preceding urlMappings
element, imagine that there is an articles page that dynamically returns
articles based on category and article identifier. The url shows the preferred
user interface, but the mappedUrl attribute shows the actual page and
parameters that will be requested.
Regrettably, you cannot use regular expressions in the urlMappings
configuration element introduced by ASP.NET 2.0.
In this sample, we used URL rewriting to organize required information
into a logical hierarchy or to mask query string parameters, all of which were
achieved by a great tool URLRewriter.dll written by Scott Mitchell. You can
download this tool from here.
For detailed implementation, please refer to the contents in
file web.config and I highly recommend you also refer to Scott Mitchell's
article on MSDN.