1. How to use Asp to determine the virtual physical path of your website
A: Use the Mappath method.
|
<P align = "center"> <font size = "4" face = "Arial"> <B> The Physical path to this virtual website is: </B> </font> <Font color = "# FF0000" size = "6" face = "Arial"> <% = Server. MapPath ("\") %> </Font> </p> |
2. How do I know the browser used by the user?
A: Use the Request object method.
|
StrBrowser = Request. ServerVariables ("HTTP_USER_AGENT ") If Instr (strBrowser, "MSIE") <> 0 Then Response. redirect ("ForMSIEOnly.htm ") Else Response. redirect ("ForAll.htm ") End If |
3. How to calculate the average number of repeated visits per day
Answer: Solution
|
<% Startdate = DateDiff ("d", Now, "01/01/1990 ") If strdate <0 then startdate = startdate *-1 Avgvpd = Int (usercnt)/startdate) %> |
Display result
|
<% Response. write (avgvpd) %> That is it. this page have been viewed since November 10, 1998 |
4. How to display random images
A:
|
<% Dim p, ppic, dpic Ppic = 12 Randomize P = Int (ppic * rnd) + 1) Dpic = "graphix/randompics/" & p & ". gif" %> |
Display
5. How to return to the previous page
A:
|
<A href = "<% = request. serverVariables (" Http_REFERER ") %>"> preivous page </a> |
Or use an image, such:
6. How to Determine the IP address of the other party
A:
|
<%= Request. serverVariables ("REMOTE_ADDR) %> |
7. How to link to an image
|
<% @ Ages = vbscript %> <% Response. expires = 0 Strimagename = "graphix/errors/erroriamge.gif" Response. redirect (strimagename) %> |
8. Force password input dialog box
A: Put this sentence at the beginning of the page.
|
& Lt; % response. status = "401 not Authorized" Response. end %> |
9. How to pass variables from one page to another
A: Use the HIDDEN type to pass variables.
|
<% Form method = "post" action = "mynextpage. asp"> <% For each item in request. form %> <Input namee = "<% = item %>" type = "HIDDEN" Value = "<% = server. HTMLEncode (Request. form (item) %>"> <% Next %> </Form> |
10. Why do I use msgbox in an asp program? If a program error occurs, I have no permission.
A: Because asp is run on the server, if you can display a dialog box on the server, you have to wait until someone presses OK before your program can continue to run, generally, the server won't be guarded by anyone, so Microsoft has to disable this function and tell you (:) that you have no permission. However, the combination of ASP and client scripts can display a dialog box, as follows:
|
<% YourVar = "test dialog box" %> <% Script language = 'javascript '> Alert ("<% = yourvar %> ") </Script> |
11. Is there any way to protect your source code?
A: You can download a Microsoft Windows Script Encoder, which can encrypt asp scripts and client javascript/vbscript scripts... However, after the client is encrypted, only ie5 can be executed. After the server script is encrypted, only ie5 can be executed if script engine 5 is installed on the server.
12. How can I transmit a query string from one asp file to another?
A: Response. Redirect ("second. asp? "& Request. ServerVariables (" QUERY_STRING "))
13. Does the global. asa file always fail?
Global. asa is valid only when the web directory is set to web application, and global. asa is valid under the root directory of a web application. IIS4 can use Internet Service Manager to set application setting. How can I make the htm file execute script code like an asp file?
14. How can I make the htm file execute script code like an asp file?
Answer: Internet Sevices Manager-> select default web site-> right mouse key-> menu properties-> Home Directory-> Application Setting) -> click "Configure"-> app mapping-> click "Add"-> executable browse and select \ WINNT \ SYSTEM32 \ INETSRV \ ASP. dll extension input htm method exclusions input PUT. DELETE is all determined, but it is worth noting that the htm should also be implemented by asp. dll processing, efficiency will be reduced
15. How to register Components
A: There are two methods,
Method 1: manually register the DLL. This method is used from IIs 3.0 to IIs 4.0 and other Web servers. it needs to be executed in the command line mode, enter the directory containing DLL, and enter: \ regsvr32 component_name.dll such as c: \ temp \ regsvr32 AspEmail. dll, which registers the specific dll information into the registry on the server. Then this component can be used on the server, but this method has a defect. After the component is registered using this method, the component must have the permission to execute the dll by setting the NT anonymous account. In particular, some components need to read the Registry. Therefore, the method of registering this component is to cancel the registration of this dll only when there is no MTS on the server, and use: regsvr32/u aspobject. dll example c: \ temp \ regsvr32/u aneiodbc. dll
Method 2: using MTS (Microsoft Transaction Server) MTS is a new feature of IIS 4, but it provides great improvements. MTS allows you to specify that only privileged users can access components, greatly improving the security settings on the website server. To register a component on MTS, follow these steps: I) Open the IIS console. II) Expand transaction server, right-click "pkgs installed" and select "new package" III) Click "create an empty package" IV) Name the package V) specify the administrator account or use "interactive" if the server often uses administrator to log in) VI) Right-click the expanded "components" under the package you just created ". Select "new then component" VI) Select "install new component" [B] VII) Find Your. dll file and select next to complete. To delete this object, you only need to select its icon and then select delete. note: pay special attention to the second method. It is the best way to debug your own component, instead of restarting the machine every time.