Support Your Customers with an Online Help Desk: Part II
Web Site Configuration and Web Form Design
By Bipin Joshi
In Part I we developed a set of classes that are essential for
our help desk application. Now it s time to start developing the Web site. To
begin, we ll configure our Web site to use forms authentication. We ll
configure authentication, membership, roles, and e-mail service via
configuration files. All the user interface attributes such as fonts and colors
are stored in a theme. Further, we ll need a couple of master pages applied to
various Web forms. Finally, we ll need user registration and log-in capabilities.
We ll make use of such ASP.NET AJAX server controls as UpdatePanel,
UpdateProgress, and Timer, which make Web applications more responsive, rich,
and user friendly.
Configuring the Connection String
To begin, add a database connection string in the
section. This connection string points to the HelpDeskDb database we created in
Part I. Open the web.config file in Visual Studio and
modify its section as shown here:
The name of the connection string is connectionstring; it
points to the HelpDeskDb database. Make sure to change the connection string to
suit your environment. This connection string is used by the
and sections later.
The help desk application consists of different areas for
customers and support personnel. This requires some authentication scheme to
validate the users. We ll use Forms authentication in our application and the
section to configure it:
The mode attribute of the section
specifies the authentication mode as Forms. The tag inside the
section configures the login page to be Login.aspx using the loginUrl
attribute. This is how ASP.NET knows where to redirect users for logging in if
they are not yet authenticated. Simply adding the
section is not enough. You also need to ban all the anonymous users from
accessing the site with the help of the section. The
tag inside the section sets the users attribute to ?,
indicating that access to all the users whose identity is in question is to be
Configuring Membership and Role Providers
The section simply enables Forms-based
authentication. We use Membership features of ASP.NET 2.0 for user validation. To
use Membership features the underlying database must be configured using the
aspnet_regsql.exe tool. To save some space we won t discuss this tool here, but
make sure to run this tool on the HelpDeskDb database so as to create the required
tables and stored procedures. Once the database is configured for Membership
features add to the web.config file the markup shown here:
The section adds a membership provider
named MyProvider. The connectionStringName attribute points to the connection
string we defined earlier. Finally, the type attribute specifies the type that
is acting as the membership provider (SqlMembershipProvider in our example).
The help desk application needs to implement role-based
security because some pages are accessible to customers and some are not. We
need two roles: Customer and SupportPerson. Before we create these roles in the
system it is important to configure a role provider. To do so, add a
section to the web.config file:
The tag enables role features by
setting its enabled attribute to true. It then adds a role provider named
MyProvider. The connectionStringName attribute is the same as before, but
notice the type attribute this time it is SqlRoleProvider.
Configuring E-mail Service
After support personnel responds to an issue, the help desk
application sends an e-mail notification to the customer. This calls for
configuring SMTP service in the web.config file. The
section takes care of this configuration:
Notice that the section comes under the
configuration section. Furthermore, notice that the
section is outside the section. The from attribute of the section
specifies the sender s e-mail address. This way you need not specify a sender s
e-mail address while sending e-mails from your code. Make sure to change this
address as per your requirements. The tag configures the SMTP
host as localhost. Instead of localhost, you can specify your own SMTP server.
The defaultCredentials attribute indicates whether to use Windows user
credentials for authentication purposes. If you wish to use specific user
credentials for authentication purposes, use the UserName and Password
attributes of the tag.
Now that we ve finished configuring the Web site, let s create
a theme. Right-click the Web site in Solution Explorer and choose Add ASP.NET
Folder | Theme (see Figure 1).
Adding a new theme.
Name the theme MyTheme. Then right-click on the MyTheme
folder and select Add New Item. Doing so will open the Add New Item dialog box
(see Figure 2).
Adding a new style sheet.
Using the Add New Item dialog box, add a new style sheet named
StyleSheet.css. The style sheet simply contains some CSS attributes for the
Using the Add New Item dialog box, add a Skin file named
SkinFile.skin. Skin files contain user interface attributes (color, font, width,
etc.) for server controls. In our example we need skins as shown in Figure 3. The
complete markup of SkinFile.skin is shown in Figure 4.
Represents a skin for Label controls that are acting as the
heading of a Web form.
Represents a skin for Label controls that display
messages to the end user.
Represents a skin for Label controls that act as the main
heading on master pages.
Represents the default skin for Label controls.
Represents a skin that is applied to HyperLink controls
used for navigation purposes.
Represents the default skin for GridView controls.
Represents the default skin for FormView controls.
Represents the default skin for DataList controls.
Figure 3: List of
skins used by various server controls.