ASP Tips Top 10 (Turn) (d)

Source: Internet
Author: User
Tip 9 How to update a locked DLL
If you are using visual Basic COM components, you must know that the error message "Cannot update DLL files, Access forbidden" that appears when updating component versions, may have been rejecting by it many times. Here is a small batch command file that you can use to automatically start or close the lock DLL file MTS.

Ask:

The ASP and a Visual Basic 6.0 DLL file are running on IIS 4.0, which is used to provide data services for ASP pages. The problem is that when we want to upgrade a DLL on a Web server to a new version, the system always shows that the DLL file is in use, neither uploading nor registering the new DLL. We have tried to close the Web site and IIS, but the DLL file is still in use. The only way seems to be to shut down the server. As you know, it's obviously not appropriate to shut down the server at runtime. Do you have a way to solve this problem? There is a 16-bit tool software WPS can shut down the DLL, however, it cannot be used for VB6 DLL files.

For:

The DLL file cannot be updated because Microsoft Transaction Server (MTS) has opened an instance of the DLL and must use Mtxstop to close it. First, create a batch command file Flushcache.bat and enter the following in the file:
net stop iisadmin/y
Mtxstop
net start w3svc




Run the batch command file. It will shut down the Web server and restart it in about 5 seconds. It clears the MTS buffer between shutting down and starting two operations, and then you can update the DLL file.

When you run a batch command file for the first time, be aware of other services that are turned off (such as FTP services, and so on). Write down these closed services, and then open the batch command file, adding code to make these services restarted:
NET start < service name >




On the June 03, 2000, Bill Bassett proposed another way:

A simpler way to solve the problem is to configure the application so that it runs in its own separate memory space. Run IIS MMC, right-click the branch that contains the target application, and select Properties. In the Application Settings section in the middle of the Properties dialog box, enter the name of the application and select the "Run in separate memory space" check box.

When the application is running, you can see that the Uninstall button has become available as soon as you open its properties page again. Click this button to apply uninstall and you can update the DLL file. The operation does not cancel the registration of the DLL, so the work is done manually with Regsvr32. This approach is better than shutting down services such as IIS and then restarting them.

10. record File Download log
This is a simple but practical technique for monitoring how many users download files from a Web site.

Ask:

We need to monitor the user's file download operation on the site. When the user clicks on the link to download the file, we want to be able to run an ASP file to write the log data to the SQL Server database, and then perform the download operation. The question is, how can ASP pages download files to the client after logging data is logged?

For:

The trick is to start a second "backstage" script with a hyperlink that logs the download log and starts the download process. As long as the second page does not produce any HTML output, the user's browser will still display the first page.

The following is an example of a link in the first file:

Download Code.zip (do not click on this link, it is only for demo, without any actual functionality.) )

The above links are created by the following code:
< A href= "Dnladd.asp?filename=code.zip" >download code.zip</A >




When the user clicks the link, we pass the filename to the second file dnladd.asp. Dnladd.asp contains scripts to write download file names and other information to the database. After you complete the database operation, dnladd.asp starts the download process with the following code:
Response.ContentType = "application/x-zip-compressed"
Response.Redirect request ("filename")




Note: Do not output any HTML code in the dnladd.asp.



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.