1. How to use Asp to determine the virtual physical path of your website
Answer: Use the Mappath method
palig=centerfontsize=4face=Arialb
ThePhysicalpath tothisvirtualwebsiteis
bfont
fontcolor=#FF0000size=6face=Arial
%=Server.MapPath()%
fontp
2. How do I know the browser used by the user
Answer: Use theRequestobject method
strBrowser=Request.ServerVariables(HTTP_USER_AGENT)
IfInstr(strBrowser,MSIE)0Then
Response.redirect(ForMSIEOnly.htm)
Else
Response.redirect(ForAll.htm)
EndIf
3. How to calculate the average number of repeated visits per day
Answer: Solution
%startdate=DateDiff(d,Now,01011990)
ifstrdate0thensstartdate=startdate-1
avgvpd=Int((usercnt)startdate)%
Show results
%response.write(avgvpd)%
thatisit.thispagehavebeenviewedSinceNovember10,1998
4. How to display random images
%dimp,ppic,dpic
ppic=12
randomize
p=Int((ppicrnd)+1)
dpic=graphixrandompics&p&.gif
%
show
imgsrc=%=dpic%
5. How to return to previous page
Answer: ahref=%=request.serverVariables(Http_REFERER)%preivouspagea
Or use pictures such as:
imgsrc=arrowback.gifalt=%=request.serverVariables(HTTP_REFERER)%
6. How to determine the other party’s IP address
Answer: %=Request.serverVariables(REMOTE_ADDR)%
7. How to link to a picture
Answer: %@Languages=vbscript%
%response.expires=0
strimagename=graphixerrorserroriamge.gif
response.redirect(strimagename)
%
8. Force password input dialog box
Answer: Put this sentence at the beginning of the page
%response.status=401notAuthorized
response.end
%
9. How to pass variables from one page to another
Answer: Use the HIDDEN type to pass variables
%formmethod=postaction=mynextpage.asp
%foreachiteminrequest.form%
inputnamee=%=item%type=HIDDEN
value=%=server.HTMLEncode(Request.form(item))%
%next%
form
10. Why do I use msgbox in the asp program? The program error says there is no permission
Answer: Since asp is run by the server, if a dialog box can be displayed on the server, you have to wait until someone presses OK before your program can continue to be executed. Generally, there will be no one on the server, so Microsoft has to ban this function and tell you that there is no permission. However, ASP and client scripts can display a dialog box, as follows