Third-party server components

Source: Internet
Author: User
Tags definition empty error handling file upload iis numeric value versions microsoft iis
Server


In this section, a brief overview of some of the common commercial and free Third-party server components to be used in the ASP system.
When you develop a Web site, the two tasks that you must complete are managing compatibility and uploading files to the server. The two components described below can help you with the above tasks, and also introduce another component that replaces Microsoft's registry access component, which is typically obtained from the appropriate Web site.
In Appendix G, a list of some of the most useful components is given.

6.3.1 Browserhawk Components
Many people who use the browser capability component provided by IIS and ASP encounter a problem, and the browser definition file (Browscap.ini) requires regular maintenance or replacement to keep up with the requirements of the new browser.
Cyscape offers an upgraded version of Broscap.ini, along with its own components that enable browser detection on both the server and the client side. It also provides a convenient graphical interface for viewing and modifying your own browser definition files, as shown in Figure 6-26:

You can see that for each browser type, there are many attributes, such as Dynamic HTML, style sheet, javascript version, file upload capability, SSL (Secure Sockets Layer) support, operating system details, and languages. As with Microsoft's browser capability component, you can add your own content. There is also a very useful wizard-style feature that can help us add new browser types to the definition file, as shown in Figure 6-27:

The Browserhawk component has the ability to identify new browsers (with a special pattern-matching algorithm) and a range of browsers that are supported by default, including opera and WebTV. It is also easy to add new properties using the filter feature.
Of course, the biggest advantage of the Browserhawk component is that it is possible to automatically detect a new version of the browser definition file from the Cyscape company's Web site on a regular basis and incorporate some content into the currently used definition file. This means there is no need to constantly copy the definition files to all Web servers.
Browserhawk components are easy to use and are compatible with browser capability components, and you need to change ProgID in the Server.CreateObject method or <OBJECT> element that creates the component instance. Put "MSWC." BrowserType "to" Cyscape.browserobj ".
Set Objbcap = Server.CreateObject ("Cyscape.browserobj")
For issues that may arise, you should read the documentation for the Browserhawk component. Copies of Browserhawk can be downloaded from the Cyscape company's Web site (http://www.cyscape.com). This chapter already contains a sample Web page that uses the Browserhawk component to give readers an idea of how to use the Browserhawk component and find this sample page in the Browserhawk subdirectory of the Chapter06 directory.
6.3.2 Sa-fileup Components
On many web sites, a general requirement is what is the ability of the server to accept the files sent by the client? In IIS 4.0, Microsoft provided a Posting Acceptor component to do this, and the component is not available in the standard installation of IIS 5.0 and ASP 3.0, which is required if you install site Server Express. You can download the component from the Microsoft Web site http://www.microsoft.com/windows/software/webpost/post_accept.htm.
However, many people find that Posting acceptor components are functionally limited and difficult to program. Now a popular alternative is the Sa-fileup component from software artisans. Unlike the Posting Acceptor component (an ISAPI filter only), the Sa-fileup component is a true ActiveX DLL server component that is easily integrated into an ASP Web page. This means that you can use the same technologies that are used on other ASP pages or components to set page security and restrict user access. The component can also be run on a mts/com+ environment.
Tutorials using the Sa-fileup component can be found on the http://www.activeserverpages.com/upload/site, so only the results are given here. The example in this chapter includes a sample page that uses the component (in the Safileup subdirectory under the Chapter06 directory) to learn how to use the component and, if necessary, from the Software Artisans Web site http:// A copy of the sa-fileup is downloaded from the www.softartisans.com/.
Using the Sa-fileup component
The sample page of the Sa-fileup component creates a simple page that contains a FILEUPLOAD element and a button, and uses the HTML INPUT element, as shown in Figure 6-28:

<form action= "Safileup_response.asp"
Enctype= "Multipart/form-data" method= "POST" >
...
<input type= "FILE" name= "FILE1" >
...
<input type= "SUBMIT" name= "SUB1" value= "Upload File" >
...
</FORM>
When the user submits the form, the content is routed to the server, and the ASP page creates a component instance and begins uploading the information to the server, which later returns a series of data describing the uploaded file, as shown in Figure 6-29:

The Sa-fileup component reads the file and registers it on the server in the form of a standard disk file or binary database data. With it, you can use ASP to control the upload process, limit the size of the upload file, or even delete the upload file, can also dynamically change its name and upload file location.

6.3.3 Regex Registry Access Component
A sample component provided by Microsoft IIS 4.0 can access the system registry on the server. This feature helps you check the version of software that you install, or check the various parameters used by IIS and the operating system.
This component was canceled in IIS 5.0, but can be obtained from other commercial versions if this feature is required. The Regex component is one of those that can access any part of the Local machine registry (if the current user is allowed to access it). In anonymous access to an ASP page, the current user is the IUSR_machinename account.
1. Members of the Regex component
The Regex component provides four ways to read and write the registry and a way to access the internal component version information, as shown in table 6-11. All information and documentation is available with the Regex component and its beta version can be downloaded from the http://www.stonebroom.com/. The sample page that comes with it is included in the example provided in this book, but you need to download the component itself.
Table 6-11 RegEx Component method and description
Method
Description

GetRegValue (registryhive,subkeystring)
Returns the default value of the given subkey from the registry, and returns an empty string if its value is inaccessible

Setregvalue (Registryhive,subkeystring,
NewValue)
In the given subkey, create or update the "default" value and set the data type to REG_SZ (string). Returns true if the update succeeds, otherwise returns false

Getregvalueex (Registryhive,subkeystring,
Valuemane,valuetype)
Returns a named value from a specific subkey, updating the variable specified by the last parameter of the method, using the data type that returns the numeric value. If the value is not accessible, an empty string is returned and reg_error as the data type

Setregvalueex (Registryhive,subkeystring,
Valuename,newvalue,valuetype)
Creates or updates a named number in a given subkey, setting the data type to the type Data_type specified by the last parameter of the method. Returns true if the update succeeds, otherwise returns false

Getinternalversionnumber ()
Returns the build number of the component, if it is a test version, and the return value contains the information

2. Using the Regex component
The Regex component provides a sample program, written in Visual Basic, that you can use to experiment with the methods it contains, which uses the Regex component to allow any portion of the system registry to be read or written to one of the supported data types or to the default string data type, as shown in Figure 6-30. A warning is displayed before any updates are made to prevent unexpected actions.

There is also a simpler ASP instance that displays some of the data in the Web server registry and allows you to read and set a Test subkey. You can modify this page and use it in your own application without restrictions. Figure 6-31 shows the results of running on NT4 and IIS 4.0.


Keep in mind that changing the values in the registry may cause the system to work abnormally, and that you should back up the registry files before you edit the contents of your registry.

6.4 Summary
This chapter discusses how ASPs can use server components to add features that other components cannot provide, and also consider the difference between server components and other types of ASP objects, such as ASP-built objects and objects in the Script Runtime library.
After studying the installable components provided by ASP 3.0 and IIS 5.0, we introduced three commercial components that provide the functionality of the general requirements, as well as several common components that can be downloaded from the web, some of which are free or shared/beta versions. However, so far we still have a very important component not involved, it is ADO. Before discussing this issue, let's discuss another basic issue: error Handling and program debugging.




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.