
C# ПІДРУЧНИКИ / c# / Hungry Minds - ASP.NET Bible VB.NET & C#
.pdf

You can add actions to a file type by using the File Types Editor. You can also specify the tasks that can be performed by a user with the files of the specified file type. An action appears in the shortcut menu when a user right -clicks the file of the specified file type. You can associate actions with a file type by following these steps:
1.Select the file type to which an action is to be added. Select Action → Add Action. This results in adding a New Document Action node in the File Types Editor. Specify the name of the newly added action. The name of the action appears in the shortcut menu when you right-click a file.
2.Select the Verb property from the properties window and type the verb. This verb will be used in the application code to specify the tasks to be performed when the action is selected from the shortcut menu.
You can also specify a particular action to be the default action for a file type. The default action occurs when a user double-clicks a file of the specified file type. You specify an action to be the default action by selecting an action node from the File Types Editor and selecting Action → Set As Default.
User Interface Editor
When you create a deployment project, it automatically creates some dialog boxes that are displayed during the installation of the application on the target computer. The User Interface Editor displays the dialog box names and enables you to specify the properties of the dialog boxes, such as the message to be displayed in a dialog box and the name of the dialog box. In addition, the User Interface Editor enables you to add your own dialog boxes.
The User Interface Editor is divided into two sections, Install and Administrative Install. The Install section contains the dialog boxes that are displayed to the users when they start installation. The Administrative Install section contains the dialog boxes that are displayed when a network administrator moves the installer to a network location, to make it available for installation over a network.
Each section has some predefined dialog boxes, which are categorized as follows:
§Start dialog boxes: Displayed to the user before the actual installation process begins. Examples of dialog boxes in this category are the Welcome screen, the dialog box that accepts customer information such as the username and company name, and the dialog box that enables a user to specify the directory in which the files are to be copied.
§Progress dialog boxes: Used as a means of providing visual feedback to the user about the progress of the installation process. It typically depicts the progress in terms of the percentage of completion of the process.
§End dialog boxes: Used to inform the user about the success or
failure of the installation process. They also include the dialog boxes that enable you to launch the newly installed application or to restart the computer.
Figure 21-9 depicts the User Interface Editor.

Figure 21-9: User Interface Editor
Adding installation dialog boxes
You can add your own installation dialog boxes by using the User Int erface Editor. The procedure for creating custom dialog boxes is as follows:
1.Open the User Interface Editor by clicking the User Interface Editor button in the Solution Explorer window, as shown in Figure 21-10.
Figure 21-10: User Interface Editor button in Solution Explorer
2.In the User Interface Editor, click the Start, Progress, or End node to add a dialog box of a particular type.
3.Select Action → Add Dialog. This will invoke the Add Dialog dialog box, shown in Figure 21-11. Select the dialog box that you wish to add.

Figure 21-11: Add Dialog dialog box
For example, you may select to add the License Agreement dialog box. You can select the License Agreement dialog box from the Add Dialog dialog box. You can specify the text to be displayed in the license agreement in a file and save the file in Rich Text Format (RTF). To associate the file with the License Agreement dialog box, you need to add the file to the deployment project by using the File System Editor. After the file is included in the deployment project, you can associate it with the License Agreement dialog box by using the Properties window and specifying the name of the RTF file in the LicenceFile property. When you run the setup, it will display the standard License Agreement dialog box with the text from the RTF file.
Changing the sequence of dialog boxes
After adding the necessary dialog boxes, you might want to change the sequence in which they appear during the installation process. You can change the sequence of the dialog boxes by selecting the dialog box and selecting the Move Up or Move Down option from the Action menu.
Removing dialog boxes
To remove a dialog box from the deployment project, select the dialog box and press the Delete key. Alternatively, you may select Edit → Delete.
Custom Actions Editor
You might want to perform some tasks on the target computer as soon as the installation process is complete. For example, you might want to execute a program that starts a Web service as soon as the process of installation is complete. Another example is when you want to create a database on the target computer during installation. The Custom Actions Editor enables you to specify such additional actions to be performed after the completion of the installation process. The actions that you want to perform must be compiled into a DLL or EXE file and added to the deployment project by using the File System Editor.
Figure 21-12 shows the Custom Actions Editor in a deployment project.

Figure 21-12: Custom Actions Editor
The Custom Actions Editor displays four folders: Install, Commit, Rollback, and Uninstall. Each folder corresponds to a phase in the installation process. The folder in which you created a particular custom action determines the sequence in which that custom action is performed.
Adding a custom action
To add a custom action to the deployment project, follow these steps:
1.Open the Custom Actions Editor in the deployment project by clicking the Custom Actions Editor button in Solution Explorer, as shown in Figure 21-13.
Figure 21-13: Custom Actions Editor button in Solution Explorer
2.Select Action → Add Custom Action. This invokes the Select Item In Project dialog box.
3.From the Select Item In Project dialog box, select the DLL or EXE file that contains the custom action to be performed during or after installation.


Building a deployment project
After you have specified the various files to be included in the deployment project, user interface screens, launch conditions, and custom actions, you can build the deployment project by selecting Build → Build. When you build the deployment project, it results in creation of the CAB, MSM, or MSI file, depending on the type of the deployment project. You can use the resulting file to install your application on the target computer.
ASP.NET Configuration System
When you install a new application, you may be required to configure it. For example, you may need to provide information about the amount of memory to be used by the application. In addition, you may need to specify application-specific information, such as the path for the data source. A configuration system provides all this information for an application, which may be used at the time of or after the deployment of the application.
A Web application should provide a flexible configuration system that allows configuration settings to be easily applied to the application. It should also facilitate easy customization of configuration settings after the deployment of the application so that changes in the configuration settings can be applied to the application without having to recompile the entire code. In addition, the configuration system should provide a rich set of configuration settings to enable different types of Web clients to work with the applications.
The configuration system provided in ASP.NET meets all of these requirements. It provides a flexible configuration system, as well as a rich set of initial configuration settings. A thorough understanding of the configuration system helps you to easily specify the settings for the target computer. You can also easily change the settings after the application is deployed.
In ASP.NET, the configuration file Web.config stores the information about browser capabilities, compilation, custom error messages, security, and globalization. The Web.config file stores the configuration information in an XML format; therefore, it can be easily read and modified by developers by using any standard text editor. Developers can also use scripting languages such as Perl and VBScript to navigate, interpret, and modify the configuration settings specified in the file.
The Web.config file can have various configuration sections for specifying configuration settings. These sections have already been covered in Chapter 14. A recapitulation of the different sections is summarized in Table 21-1.
Table 21-1: Configuration sections in ASP.NET
Section |
|
Configuration Section |
|
Description |
|
|
Handler in ASP.NET |
|
|
|
|
|
|
|
AppSettings |
|
System.Configuration. |
|
Enables you |
|
|
to specify |
||
|
|
NameValueFileSectionHandler |
|
|
|
|
|
custom |
|
|
|
|
|
|
|
|
|
|
configuration |
|
|
|
|
settings for |
|
|
|
|
your |
|
|
|
|
application. |
|
|
|
|
You can use |
|
|
|
|
one or more |
|
|
|
|
<add> |
|
|
|
|
elements in |
|
|
|
|
this section to |
|
|
|
|
add a new |
|
|
|
|
key and |
|
|
|
|
specify the |
|
Table 21-1: Configuration sections in ASP.NET |
|
|
|
||
|
|
|
|
|
|
|
|
Section |
|
Configuration Section |
|
Description |
|
|
|
|
Handler in ASP.NET |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
values for the |
|
|
|
|
|
|
same. |
|
|
|
|
|
|
|
|
|
Authentication |
|
System.Web.Configuration. |
|
Enables you |
|
|
|
|
AuthenticationConfigHandler |
|
to specify the |
|
|
|
|
|
|
default |
|
|
|
|
|
|
authentication |
|
|
|
|
|
|
mode, and |
|
|
|
|
|
|
specify cookie |
|
|
|
|
|
|
authentication |
|
|
|
|
|
|
settings. |
|
|
|
|
|
|
|
|
|
Authorization |
|
System.Web.Configuration. |
|
Controls client |
|
|
|
|
AuthorizationConfigHandler |
|
access to the |
|
|
|
|
|
|
ASP.NET |
|
|
|
|
|
|
resources at a |
|
|
|
|
|
|
given URL. |
|
|
|
|
|
|
|
|
|
BrowserCaps |
|
System.Web.Configuration. |
|
Controls the |
|
|
|
|
HTTPCapabilitiesSectionHandler |
|
settings of the |
|
|
|
|
|
|
HttpBrowser |
|
|
|
|
|
|
Capabilities |
|
|
|
|
|
|
component, |
|
|
|
|
|
|
which enables |
|
|
|
|
|
|
you to gather |
|
|
|
|
|
|
the |
|
|
|
|
|
|
information |
|
|
|
|
|
|
about the |
|
|
|
|
|
|
browser |
|
|
|
|
|
|
running on the |
|
|
|
|
|
|
client. |
|
|
|
|
|
|
|
|
|
Compilation |
|
System.Web.Configuration. |
|
Contains the |
|
|
|
|
CompilationConfigHandler |
|
compilation |
|
|
|
|
|
|
settings that |
|
|
|
|
|
|
are used by |
|
|
|
|
|
|
ASP.NET for |
|
|
|
|
|
|
compiling a |
|
|
|
|
|
|
Web |
|
|
|
|
|
|
application. |
|
|
|
|
|
|
|
|
|
CustomErrors |
|
System.Web.Configuration. |
|
Enables you |
|
|
|
|
CustomErrorsConfigHandler |
|
to specify the |
|
|
|
|
|
|
page to which |
|
|
|
|
|
|
the |
|
|
|
|
|
|
application |
|
|
|
|
|
|
should be |
|
|
|
|
|
|
redirected in |
|
|
|
|
|
|
the event of |
|
|
|
|
|
|
an error. |
|
|
|
|
|
|
|
|
|
Globalization |
|
System.Web.Configuration. |
|
Specifies the |
|
|
|
|
GlobalizationConfigHandler |
|
globalization |
|
|
|
|
|
|
settings for an |
|
|
|
|
|
|
application. |
|
|
|
|
|
|
|
|
|
HttpHandlers |
|
System.Web.Configuration. |
|
Maps the |
|
|
|
|
HTTPHandlersConfigHandler |
|
incoming URL |
|
|
|
|
|
|
|
|