Feed on
Subscription

ASP series lecture (two ten one) found routine script

Commercial application process often needs to have the capacity that runs script and package in clerical interior.General affairs is operation of a kind of server,Although this operation includes a lot of measure (for example,Indent, examine goods in stock, pay the bill etc) ,Also can whole returns an operation is success or failure.The user can found the ASP scenario that runs in clerical interior,If any one part of script fails,Whole routine will be stopped.

Processing of ASP general affairs is with Microsoft%26reg;Transaction Server (MTS) is a foundation.Microsoft%26reg;Transaction Server (MTS) is processing system of a general affairs,Use at development, configuration and management high-powered, can classification, the enterprise Internet that has rash club sex and process of application of Intranet server.Transaction Server is development distributed,The applied process that is based on package provided an application programming model.It also applied a program to provide a moving environment to configure and manage these.

The buy inside the function that founds routine script is in Internet Information Server and Personal Web Server.If you installed Microsoft Transaction Server,Can bale package,In order to make package moves in clerical interior.

About general affairs
The operation that general affairs is integral success or failure.Clerical processing is used at undertaking to the database reliable ground is updated.When undertaking to the database heterogeneous closes to change or update many databases at the same time making,Should assure all changing to be carried out correctly.If these change medium any,fail,The savagery that needs to restore a database to express.

If do not have MTS,You write script and package with respect to need,Dog by hand of the request change a condition,So that be in certain data restores when changing failure.Use MTS,You need the simple script you and package statement to be only " need general affairs " the consistency that lets MTS handle work.Clerical processing applies to a database to visit only;MTS cannot is opposite file system or other blame are routine of resource change undertake resumptive to operate.The database that uses program place visit must support for MTS place.At present,SQL Server of MTS support reachs agreements of any supportive XA (make by X/Open association) server.MTS will continue to expand the support of pair of other databases.

General affairs cannot span page of many ASP.If a general affairs needs to come from the object of many component,Need the operation combination that will use these targets to be in page of an ASP.For example,Assume have a package at updating payroll database with,The employee in still a component is used at updating manpower resource database is recorded.To record the new salary information of an employee,You need to write a such script,This script calls these two package in environment of a work,One at updating payroll database with,Another employee social estate that is used in database of resource of newer labor power.

Statement is routine script
In a page statement is routine when,Any script commands in this page and object move in same a clerical environment is medium.Processing of Transaction Server generates clerical detail and decision general affairs succeeds (refer) or failure (stop) .Should be statement of a certain page routine,Can be in page head adds @TRANSACTION to dictate:

%26lt;%@ TRANSACTION = Value %%26gt;
Value parameter can be following one of:

Value sense
Requires_New starts a new work.
Required starts a new work.
Supported does not start work.
Not_Supported does not start work.

@TRANSACTION instruction must be in one of one page,Will produce a mistake otherwise.In the each page that must add this statement need to move below general affairs.When script handles an end,Current general affairs announces an end namely.

Process of great majority application has a few specific operations to need clerical environment only.For example,The site of an airline may need routine script processing to buy ticket and arrangement seat only,And other and all script is beardless clerical environment can safety moves.The page that because clerical simply is used at needing work,handles can,The statement of Global.asa file that will not use a program is routine.

If general affairs is stopped,Transaction Server will restore the resource to supporting work any changing.At present,Only database server supports work completely,Because amount to occupies the data in the library to apply to the enterprise,be most crucial.The file on incorrect hard disk of Transaction Server, conversation and the change that apply the variable of the program, gather to wait undertake resumptive.However you can be like article topic place to narrate,Restore variable and aggregate script through writing clerical incident to write.In certain moment,Refer or stop a work your script is OK also and explicitly,When if keep data to the file,failing.

Refer or stop script
Because Transaction Server dogs,general affairs is handled,So it decides general affairs is complete success still is failure.Script can state explicitly through calling ObjectContext.SetAbort stop a work.For example,Be in when a general affairs receive erroneous information from a component, when violating commercial standard (for example,Account remaining sum is less than 0) or read write the blame such as the file when routine operation fails,Script stops this work with respect to need.If the page is overtime before general affairs is finished,Also must stop work.

Write clerical incident
Script itself cannot decide general affairs is successful or fail.But,Can write the event that when refer or stopping work, is called.For example,The scenario that suppose one confirms bank account,And you need the different position in the light of general affairs will different page returns an user,What can use OnTransactionCommit and OnTransactionAbort incident to write pair of users so is different answer.

%26lt;%@ TRANSACTION = Required %%26gt;

%26lt;%
'Buffer Output So That Different Pages Can Be Displayed.
Response.Buffer = True
%%26gt;

%26lt;HTML%26gt;
%26lt;BODY%26gt;
%26lt;H1%26gt;Welcome To The Online Banking Service%26lt;/H1%26gt;


%26lt;%
Set BankAction = Server.CreateObject("MyExample.BankComponent" )
BankAction.Deposit(Request("AcctNum" ) )
%%26gt;

%26lt;P%26gt;Thank You. Your Transaction Is Being Processed. %26lt;/P%26gt;
%26lt;/BODY%26gt;
%26lt;/HTML%26gt;

%26lt;%
' Display This Page If The Transaction Succeeds.
Sub OnTransactionCommit()
Response.Write %26quot;%26lt;HTML%26gt; %26quot;
Response.Write %26quot;%26lt;BODY%26gt; %26quot;
Response.Write "Thank You. Your Account Has Been Credited. Your Account Has Been Credited..
Response.Write %26quot;%26lt;/BODY%26gt; %26quot;
Response.Write %26quot;%26lt;/HTML%26gt; %26quot;
Response.Flush()
End Sub
%%26gt;

%26lt;%
' Display This Page If The Transaction Fails.
Sub OnTransactionAbort()
Response.Clear()
Response.Write %26quot;%26lt;HTML%26gt; %26quot;
Response.Write %26quot;%26lt;BODY%26gt; %26quot;
Response.Write "We Are Unable To Complete Your Transaction. Response.Write "We Are Unable To Complete Your Transaction..
Response.Write %26quot;%26lt;/BODY%26gt; %26quot;
Response.Write %26quot;%26lt;/HTML%26gt; %26quot;
Response.Flush()
End Sub
%%26gt;
Manage in MTS resource implement in register a component
To share a work,Package must be registered in MTS bag,And must be to need work by configuration.For example,If your script is,handle order through calling two component to come,Database of a newer stock,Another pay newlier database.So,These two component are about to be in same a clerical environment is medium move.If,Transaction Server assures random a component fails,So will not the database is updated.Certain component does not need work;For example,Component of Ad Rotator.

Register and configure routine component to be able to use MTS resource to manage implement.The setting is need general affairs or must need clerical property new work.Clerical component must be registered in MTS bag.In putting package in process of IIS interior wrap,And the bag that should found oneself.Normally,In answering to put all package in library of a component.The component of package library can be used by process of application of many ASP and with ASP application order process moves.Resource of use MTS manages implement the setting of Activation attribute that can found new package and will include is Library.

Also can register routine component in Server bag.The course that Server includes an independence that goes up with the server normally moves.If hope to use the security examination that is based on function group or hope,the applied course that can be attended by long-range computer visits your component,Can wrap to routine component use Server.

Should use MTS resource to manage implement,Must install Microsoft Transaction Server.

Object scope
Usually,Not be the object memory that founds from inside MTS component in ASP Application or Session object.MTS object disappears after general affairs is finished.Because Session object and Application object are,design for the object example that uses between page of different ASP,The object that when protecting existence general affairs to end with them so, is released namely.

ASP script is already the root of the general affairs of reputation,Namely initial drop.The one part that the MTS target that place of any page of routine ASP use is considered as general affairs.After general affairs is finished,The MTS target that uses in the page will disappear,Include memory among them the object in Session or Application object.After this,The attempt that calls conversational scope or boy or girl friend of applied process scope from inside another routine page will fail.

General affairs queues up
The newer likelihood that occupies a library from logarithm of a long-range server causes clerical delay because of network defer or breakdown or stop.Must refer because of all parts of general affairs,So applied process hangs the likelihood,Refer or stop a message what await long-range server,Because cannot be sent,bring about general affairs possibly also to be abandoned.

Update to what must finish at the same time,Right way is before all participator in general affairs can be referred,Stop work or suspend the work that finish.For example,The program deciding a ticket of airline should complete the bank to the client at the same time account plan joins debit and the bank to airline account plan joins credit.If one replaces the one part that attributes clerical whole,But the likelihood is later than other update,You may not hope to let what the client awaits whole newer procedure finish.For example,The itinerary allowance that airline ticket books general affairs to also may want to send food order for goods or newer client to food supplier.Although these operations also must be finished,But can a few later.

Microsoft Message Queue Server makes you can will or update one group long-range server sends in binding a routine message.Message Queue Server assures to will be sent newlier to send long-range server,Although the network is not at present usable.Your application will receive to submit an information,Can continue to handle work thereby.

...

ASP series lecture (two ten) the safety that defends program of ASP application

The significance that must not underestimate proper configuration safety to install.If incorrect configuration safety is installed,Not only can make applied process suffers your ASP to distort needlessly,And the.asp file that just when the user visits you,can hamper.

The program of ASP application that Web server offerred all sorts of methods to protect you is avoided suffer not the visit of accredit and distort.After the safe news that reads this theme to fall in you,Spend constant time scrutiny please your Windows NT and documentation of security of Web server.

NTFS attributive
You can be passed visit attributive to protect document of process of ASP application for alone file and catalog application NTFS.The foundation that NTFS attributive is security of Web server,The different level that it defined or a group of users visit file and catalog.When the user that should have effective account of Windows NT tries to visit a file that has attributive restriction,The computer dominates the visit that checks a file the list (ACL) .The limits of authority that this watch defined different user and user group place to be gifted.If the account of the user has the limits of authority that opens a file,The computer allows this user to visit a file.For example,The possessory need of the process of Web application on Web server has " change " attributive will examine, the.asp file that change and deletes applied process.But,The communal user that visits this application process should be awarded only " read-only " attributive,The Web page that so that restrict its,uses a program to can be examined only and cannot be changed.

Defend the safety of Global.asa
To protect process of ASP application adequately,The Global.asa that must using a program is proper user on the file or user group sets limits of authority of NTFS file.If Global.asa is included,return the command of information to the browser and you did not protect Global.asa document,Criterion information will be returned to the browser,The other file of process of even if application is protected.

Attention The NTFS limits of authority that must consolidate to using the file application of the program.For example,The NTFS attributive of the file that if you are not careful and excessive,restricted all to need to include with the program,The user cannot be examined possibly or run this to use a program.To avoid this kind of problem,Should plan carefully before the applied process that is you allocates NTFS attributive.

Attributive of Web server
The limits of authority that you can pass the Web server that configures you will restrict all users to examine, the means of the ASP page that move and operates you.The visit means that unlike the control that NTFS attributive offers specific user correspondence uses program document and list,Application of attributive of Web server has an user at place,And do not distinguish the type of user account.

The user that uses a program to wanting to run your ASP,When setting limits of authority of Web server,Must follow following principle:

Allow to including the fictitious list of.asp file " read " or " script " attributive.
Mix to.asp file other the file that includes script (wait like.htm file) the empty catalog of the place allows " read " and " script " attributive.
To including.asp file and other need " carry out " the file that attributive ability runs (wait like.exe and.dll file) empty catalog allows " read " and " carry out " attributive.
Script map file
The source code that the script map that uses a program assured to Web server won't download.asp file accidentally.For example,Although you were the list that included file of a certain.asp to install " read " attributive,Want be subordinate to of file of this.asp to belong to map of a certain script to use a program only,So your Web server won't return the source code of this file the user.

Cookie security
ASP use SessionID Cookie dogs during applying program visit or conversation the information of specific Web browser.This that is to say,The HTTP request that contains corresponding Cookie is considered as to come from browser of same Web.Web server can use configuration of SessionID Cookies to contain an user the process of ASP application of specific and conversational information.For example,If your applied process is an allow,make user choice and the online music store that buy CD record player,Can dog with SessionID the user roams the choice when whole application process.

SessionID whether be guessed by the hacker?
The visit of the conversational variable that to prevent computer hacker to guess SessionID Cookie acquires pair of lawful users,Web server makes number randomly for assign of every SessionID.Every time when the Web browser of the user returns a SessionID Cookie,The server takes out SessionID and the number that are gifted,Check what whether go up in the server with memory to generate number to agree then.If two number are uniform,Will allow an user to visit conversational variable.The length of the number that the effectiveness of this one technology depends on be being gifted (64) ,This length makes computer hacker guesses SessionID thereby the possibility of the mobile conversation of filch user is almost 0.

Add close important SessionID Cookie
The computer hacker that intercepted and capture user SessionID Cookie can use this Cookie sham this user.If ASP applies a program to contain private information,Credit card or bank account number,In can using a program, the computer hacker of the Cookie that has filch begins an activity conversation to get these information.Link adds the communication between the browser that you can pass the Web server to you and user to prevent SessionID Cookie to be intercepted and capture closely.

Mechanism of use identity test and verify protects content of confined ASP
The user name that you can ask every user that tries to visit content of confined ASP must want to have account of effective Windows NT and password.Every time when the user tries to visit confined content,Web server will undertake identity test and verify,Confirm user identity namely,Whether to have account of effective Windows NT in order to check an user.

Web server supports way of test and verify of the following kinds of identities:

Primary status test and verify Name of user of clew user input and password.
Windows NT requests / answer style capacity test and verify Get user identity information through imposing close kind from the Web browser of the user.
However,Web server should prohibit only identity of user of test and verify of the ability when the attributive of faceless visit or system of file of Windows NT limits faceless visit.

Protect metadata library
The administrator attributive of the computer that the server of Web of need of ASP script that visits metadata warehouse runs.From these scenario run on long-range computer in,The join that beard classics already passed identity test and verify,If use Windows NT to request / means of card of noisy come true has link.Should found a server to manage file of class.asp or catalog and its setting of means of catalog safety test and verify is Windows NT to request / answer style capacity test and verify.At present,Only Microsoft Internet Explorer Version 2.0 or request of Windows NT of taller version support / answer style capacity test and verify.

Use SSL maintains the security that uses a program
Agreement of Secure Sockets Layer (SSL) 3.0 regards Web server as safe character,The fictitious and transparent way that offerred a kind of security will build with the user add secret news report to join.The test and verify that SSL assured Web content,The identity that can confirm the user that visits site of confined Web reliably.

Through SSL,The user that you can ask to try to visit confined ASP to use a program and your server builds to increase close connection;The important information that exchanges between user and applied process in case by intercept.

Maintain the security that includes a file
The file in if you were included in the.asp file from inside be located in the fictitious root catalog that did not protect,be located in the catalog that enabled SSL,Criterion SSL will be not applied at be being included file.Because of this,To assure to apply SSL,Should ensure include in reaching the file that is included to be located in the catalog that enabled SSL.

Client qualification attestation
A kind of when control the process of ASP application to you to visit very safe method is requirement user use client qualification logins.Client qualification is the digital Id that contains user identity information,The identification such as its action and traditional such as passport or driving licence is identical.User from precatory normally tripartite organization gains client competence,tripartite organization is in extend the identity information that the user confirms before qualificatory card.(normally,Full name of requirement of this kind of organization, address, telephone number and place organization name;The detailed pitch of this kind of information along with the status order and degree that offer different.)

Every time when the user tries to login to use a program to what need qualificatory test and verify,The Web browser of the user can send user qualification from tendercy server.If the map of qualification of Secure Sockets Layer (SSL) of Web server is characteristic configuration is proper,So the server can be in before permissive user is visited to process of ASP application, to its the identity undertakes affirming.

With the ASP script that proves at handling a qualification
As staff of development of process of ASP application,You can write a foot to whether original examination qualification exists and be read take qualificatory field.For example,You can visit user name from inside qualificatory proof renown field of field and company.Active Server Pages saves qualificatory information in the ClientCertificate gather of Request object.

Must configure Web server to accept or need client qualification,Just can handle client qualification through ASP next;Otherwise,ClientCertificate gather will is empty.
...

ASP series lecture (ten nine) management is conversational

One of difficult problem that develop program of Web application successfully are in user visit,Namely during conversation,Jump between the page that uses a program in when the user and page turn while,Safeguard user information.HTTP is one kind does not have state agreement,That is to say,Web server some page visit every time regard as the visit that has nothing to do each other will handle;Any information that visit before the server is not withheld one times,Before although visit,happening in a few seconds of current visit.The applied program that because this kind does not remember the character that visits before to make,writing online catalog and so on is very difficult,Process of this kind of application may need to dog the user jumps between the different page of catalog turn while the catalog that ever had chosen.

The unique program that ASP offerred to manage conversational information problem.Object of use ASP Session and the special user ID that generate by your server,You can establish program of an intelligent application,The user that should use a program to be able to identify every to call in collects applied process to dog an option of the user or the information that choice content wants to be used.

ASP installs user ID through HTTP Cookie.HTTP Cookie is memory the little file on user browser.Because of this,If you are in,use a program to do not support the browser of Cookie to found,Or your client installs the browser to do not accept Cookie,The conversation management function that does not use ASP please.

You also can write the script that in application the program is started or moves when the end.

Start and end conversation
Conversation can be started through three kinds of means:

A new user requests to visit an URL,This URL marked the.asp file in process of a certain application,And should use the Global.asa document of the program include Session_OnStart course.
The user stored in Session object one is worth.
The.asp document that the user requested an application process,And should use the Global.asa document of the program use %26lt;OBJECT%26gt;The example that label establishs the target that contains conversational scope.
Any pages in if the user is pointing to to there are request or refresh inside time surely,using a program,Conversational will automatic end.The acquiescent value of this paragraph of time is 20 minute.Can manage through serving in Internet implement in setting " applied process option " in attribute page " conversational overtime " the acquiescent overtime of process of attribute change application restricts a setting.The requirement that should use a program according to your Web and the memory space of the server will set this value.For example,If you hope to browse your Web application,the user of the program stays a few minutes only in each page,Should shorten conversational acquiescent overtime is worth.Too long conversational and overtime value will bring about the conversation that open overmuch and extinct the memory resource of your server.

To a specific conversation,If you think the setting is less than acquiescent overtime,the overtime of the value is worth,The Timeout attribute that can set Session target.For example,This paragraph of script is worth overtime the setting to be 5 below minute.

%26lt;% Session.Timeout = 5 %%26gt;
The overtime that you also can set to be more than acquiescent setting is worth,Decision of Session.Timeout attribute is worth overtime.

The Abandon method that you also can adopt Session target is explicit end a conversation.For example,One is offerred in form " exit " pushbutton,the ACTION parameter of pushbutton the setting is the URL that includes file of following jussive.asp.

%26lt;% Session.Abandon %%26gt;
About SessionID and Cookie
Request given applying when user first time when the.asp file in the program,ASP generates a SessionID.SessionID is the number that makes by a complex algorithm,It marks exclusively every user is conversational.In new conversation in the begining,The server is Session ID as memory of a Cookie in the Web browser of the user.

SessionID and key are very similar,When user and applied process are alternant during conversation,ASP can be in user information memory a of the server " safe " in.Just as can access the article in safe with the key same,Through the user SessionID Cookie that sends in caption requesting in HTTP,Can be opposite this " safe " medium content has a visit.Every time when ASP receives a page to request,With respect to caption of request of examination HTTP,In order to obtain SessionID Cookie.

In store SessionID Cookie after the browser at the user,Although the user requested document of another.asp,Or the.asp file in requesting to move in another to use a program,ASP still is met put sb in a very important position this Cookie dogs conversational.With this likeness,If the user is intended,make conversation overtime,Request document of another.asp again next,So ASP general with same Cookie begins new conversation.When when the server only the administrator starts a server afresh or the user starts Web browser afresh,Store the SessionID setting in memory will be kept clear of right now, the user will obtain new SessionID Cookie.

Through SessionID Cookie of put sb in a very important position,The Cookie measure that ASP will send user browser falls for lowest.Additional,If you decide process of your ASP application does not need conversation,manage,Need not let ASP dog conversation and send SessionID to the user.

ASP does not send conversational Cookie below the following circumstance:

The conversational position that uses a program is banned to use.
ASP page is not to have conversation by the definition,Namely this page includes %26lt;%@ EnableSessionState=False %%26gt;Mark.
Notice please,SessionID Cookie is not offerred dog the user is right the visits for many times permanent method of site of a certain Web.Memory is lost very easily in the SessionID information in server memory.The user that if want to dog to visit your Web inside a long time,uses a program,Must store through be in the Web browser of the user a special Cookie,In saving Cookie information the database, will found an user to mark.

In data of the memory in Session object
Session object offerred but the dynamic and associated array of amid memory information.You can store in Session object numeric variable and object variable.

Through naming an assignment mediumly to Session object,Can be variable memory in Session object.For example,The following command is two new variable memory in Session object:

%26lt;%
Session("FirstName" ) = "Jeff "
Session("LastName" ) = "Smith "
%%26gt;
Name through visitting this can get information from inside Session object.For example,The current value of indication Session("FirstName" ) :

Welcome %26lt;%= Session(%26quot;FirstName%26quot; ) %%26gt;
Can store in Session object an option of the user,Pass visit head option to decide to dispatch which one page the user next.For example,On the visit of all pages that the content that simple text version assigns in the first page that can allow an user to use a program in yours chooses this to apply user after this to use a program to this.

%26lt;% If Session(%26quot;ScreenResolution%26quot; ) = %26quot;Low%26quot; Then %%26gt;
This Is The Text Version Of The Page.
%26lt;% Else %%26gt;
This Is The Multimedia Version Of The Page.
%26lt;% End If %%26gt;
You also can store in Session object an object example,But the property that makes meeting influence server so.

Manage the conversation of Web Farm
Memory of ASP conversational information is in Web server.The browser must obtain the script that uses visit conversation information to ability of page of request of Web server.In Web Farm (among them a lot of Web servers assume the responsibility that answers user application jointly) in,The request of the user always is not by the road by arrive same a server,However by one is called " laden balance " the special software of the process allocates random to the application of site of this URL a disengaged server.It is more difficult that laden balance process makes save conversational information to become in Web Farm.

Manage to be gone up to use ASP conversation by the site of the balance in a load,All requests that must make sure the user is conversational by directional arrive same a Web server.A kind of practice is to write process of a Session_OnStart,Object of this process use Response weighs the browser directional to the Web server that runs this user conversation.If be in,all your links in using program page are opposite,So be opposite later all requests of some page will by the road by to same a server.

For example,The general URL that some user wants to pass request some site:Http://www.microsoft.com will visit an application process.Laden balance process will apply a logic by to server Server3.microsoft.com.ASP made a new user conversation on this server.In Session_OnStart process,The browser is weighed directional to designation server:

%26lt;% Response.Redirect(%26quot;http://server3.microsoft.com/webapps/firstpage.asp%26quot; ) %%26gt;
The page that the browser appoints the request,And the following all request will by the road by arrive same a server.

Use Cookie
Cookie is Web server is embedded in the Web browser of the user,The your card that uses delegate user.When issueing same browser to request one page,It will send the Cookie that receives from Web server.Cookie be patient of a group of information and user correlation.The Cookies of use Response of ASP script and Request object assembles,The value that can be gotten and sets Cookie.

Install Cookie
The value that should set Cookie,Can use Response.Cookies.If Cookie is nonexistent,Response.Cookies will found new Cookie.For example,Should send a concerned couplet to be worth to the browser (the Cookie name of "Mars" ) ("planet" ) ,Can use following order,These commands must appear in the %26lt;HTML of your Web page%26gt;Before mark:

%26lt;% Response.Cookies(%26quot;planet%26quot; )= %26quot;Mars%26quot; %%26gt;
If you hope only,Cookie is used in current user conversation,Need to send Cookie to the browser only.But,If want to be in,the user affirms after the new browser that start,Must enforce the browser is Cookie memory on the hard disk of the computer.Should save Cookie,The some day that can use the Expires attribute of Response.Cookies to be date setting after this:

%26lt;%
Response.Cookies("planet" ) = "Mars "
Response.Cookies("planet" ).Expires = "January 1, 1999 "
%%26gt;
Cookie can have many values;The Cookie that such Cookie is called to bring index.Value of every Cookie is gifted a key word;The value that you can set a specific Cookie key word.For example:

%26lt;% Response.Cookies(%26quot;planet%26quot; )(%26quot;Mars%26quot; )= %26quot;SpaceMissions%26quot; %%26gt;
If a certain existing Cookie has key word to be worth but Response.Cookies not demonstrate the name of a key word,Criterion this key word is worth will be deleted.Similar,If a certain existing Cookie does not have key word to be worth but the name that Response.Cookies points to clear key word and value,Existing Cookie value will be deleted,Generate new Key-value to be opposite.

Get Cookie
The value that should get Cookie,Can use Request.Cookies to assemble.For example,If the HTTP of the user requested to install Planet=Mars,Following statement will get value Mars:

%26lt;%= Request.Cookies(%26quot;planet%26quot; ) %%26gt;
Similar,Should get key word to be worth from inside the Cookie that brings index,Can use key word name.For example,If the user gives out following HTTP,request:

Planet=Mars%26Mars=SpaceMissions
Following scenario SpaceMissions of return of value:

%26lt;%= Request.Cookies(%26quot;planet%26quot; )(%26quot;Mars%26quot; ) %%26gt;
Set Cookie way
By ASP memory every Cookie in the Web browser of the user contains method information.When the position of the document that requests when the browser and the way that appoint in Cookie are same,The browser gives a server automatically Cookie transmit.Below acquiescent circumstance,Cookie method and the applied process name that include the.asp file that makes Cookie at first are corresponding.For example,If the in using a program.asp of UserApplication is in the name,the file generated a Cookie,So every time when in using a program here, the Web browser of the user gets a document,Divide other in method / outside the Cookie below UserApplication,The browser gives a server transmit of this Cookie even.

The method that should state to Cookie one is different from acquiescent applied process method,The property of Path of Response.Cookies aggregate that can use ASP.For example,Following scenario gifts method SalesApp/Customer/Profiles/ a Cookie that is Purchases:

%26lt;%
Response.Cookies("Purchases" ) = "12 "
Response.Cookies("Purchases" ).Expires = "January 1, 2001 "
Response.Cookies("Purchases" ).Path = "/SalesApp/Customer/Profiles/ "
%%26gt;
The Web browser that includes Purchases Cookie every time requests to be located in method / when the file of SalesApp/Customer/Profiles/ or its subdirectory,The browser gives a server Cookie transmit.

A lot of Web browsers,Include Microsoft Internet Explorer 4.0 and Netscape browser,The bulk that retains Cookie way is written.That is to say,If the size of a document that is requested is written,differ with the Cookie method of reservation,So the browser is won't to server transmit Cookie.For example,To ASP,Fictitious catalog / TRAVEL and / Travel is process of same ASP application,And to the browser of the big the ordinary form of a Chinese numeral of reservation URL,/ TRAVEL and / Travel is two different application programs.Should ensure all URL of.asp file have identical big small letter,In order to assure the browser of the user can the Cookie that transmit stores.

If need,Can use following statement to set Cookie way,What is no matter use program or method,making,The Web browser that wants an user only requests a document to your server,With respect to meeting transmit Cookie:

Response.Cookies("Purchases" ).Path = "/ "
But,Notice please,Cookie is sent to the server below the circumstance of process of not divisional application,If Cookie contains the sensitive information that should be not appointed to apply the program beyond the program to visit,Produce security problem possibly.

Do not use Cookie and retain position
Not all browser supports Cookie.The browser that even if uses supportive Cookie,Some users like possibly also to shut Cookie to support.The browser that if your applied process needs to answer,does not support Cookie,Must use ASP conversation to manage.

If you do not use ASP conversation,manage,So that the mechanism that must write you oneself passes information between your applied process page.The method that has two kinds of routine is achievable this task:

To the inquiry of URL string adds parameter.For example:
Http://MyServer/MyApp/start.asp? Name=Jeff
But,Certain browser,The explicit parameter that in be being discarded to inquire string by the meeting below the case that refers with GET method in form, delivers.

Add to the middle of form implicit value.For example,The following HTML form includes to accuse implicitly.This accuses do not appear in true form,And it is sightless to the Web browser of the user.Through method of HTTP POST,Form besides passing the information that the user provides,Still deliver an user to mark.
%26lt;FORM METHOD= %26quot;POST%26quot; ACTION= %26quot;/scripts/inform.asp%26quot; %26gt;
%26lt;INPUT TYPE= %26quot;text%26quot; NAME= %26quot;city%26quot; VALUE= %26quot;%26quot; %26gt;
%26lt;INPUT TYPE= %26quot;text%26quot; NAME= %26quot;country%26quot; VALUE = %26quot;%26quot; %26gt;
%26lt;INPUT TYPE= %26quot;hidden%26quot; NAME= %26quot;userid%26quot; VALUE= %26lt;%=UserIDNum(i) %%26gt;
%26lt;INPUT TYPE= %26quot;submit %26quot; VALUE= %26quot;Enter%26quot; %26gt;
All link target that this method asks to transmit user information is coded be HTML form.

If you are current conversational without use ASP managing,The applied process conversation that shuts you please supports.When conversation is enabled,ASP sends SessionID Cookie to every browser that requests ASP page.Should shut conversational support,Can keep clear of Internet serves government implement medium " applied process option " in attribute page " enable conversational condition " answer choose casing.

Without conversational ASP page
ASP also is offerred found the function that does not have conversational page,You can use this function when the will conversational ASP page that founds user of time remit to to visit conversation of a need to dog.

Do not execute the following function without conversational page:

Process of executive Session_OnStart.
Send conversational ID Cookie.
Establish Session target.
The visit uses %26lt;OBJECT%26gt;The built-in and conversational target that mark establishs or conversational scope object.
With other conversation the request is carried out orderly.
Should be.asp configuration without conversation,Can use following statement:

%26lt;%@ EnableSessionState=False %%26gt;
You answer the group of file of.asp of this script park,Before be located in other scenario.Below acquiescent circumstance,If omit this labels,Enable conversation to dog.

Through eliminating potential time-consuming conversation to operate without page of conversational ASP,The response that improves a server function.For example,Consider the following case,The frame of two HTML that ASP page includes a certain frame to center,Frame 1 and frame 2.The.asp file that frame 1 includes to carry out complex scenario,And frame 2 includes a simple.html file.Because ASP order is carried out (namely serial carry out) conversational request,Before be being carried out in the script of frame 1 so,The content that you will not see frame 2.But,If you install frame 1 to do not have conversation,Criterion ASP requests will no longer by serial processing,The content that the browser need not await to carry out the content of frame 1 to be able to handle frame 2.

But,The processing means of the many requests of different frame depends on finally even the configuration of browser of user Web.Of the.asp file that browser of certain Web may not pay attention to you without conversational configuration,All the same serial processing requests.

...

ASP series lecture (ten eight) administrative application process

Windows NT Option Pack offerred the ASP on Web server to apply program management to serve.For example,Internet serves government implement the property that offerred to use handy administrative tool to set applied program to apply a program to develop personnel.Additional,The script function that Active Server Pages provided the data of overall situation of applied process memory that allows an user.Brief introduction uses this theme partly program management function,The link that provides detailed information.

Start and end applied program
When the request that receives the ASP page in using a program when first time of Web server,Start this to use a program.When Web the server is shut or service of user use Internet manages implement go up " uninstall " when pushbutton stops to use a program,Applied process ends.The user can be in to moving only the memory space that differs with process of Web server (segregate) medium applied process is used " uninstall " pushbutton.

Segregation uses a program
Process of ASP application moves in same memory space or same process with Web server normally.Although improved the performance of process of ASP application so,But if apply a program to fail,Process of Web server is in hazardous condition.You can move in through making use a program go up unlike the memory space of Web server and keep apart this to use a program.If ASP applies a program to fail,Other application process and itself of Web server are protected.

State of use application process
When writing applied program,All users that should let use a program can obtain the information that concerns with applied process.For example,Found a few variable,The greeting picture that makes systematic manager can differ through the setting or the caption style that change all ASP pages come from the applied process that defines its site.These changing will be seen by all users that visit this site.

All users that a variety of means can make use a program obtain data from all pages that use a program.The most commonly used method is to store variable or object example in object of ASP Application,Gift for its applied process scope.Applied process scope is very useful to global data,For example global data tally or information of configuration of global application process,Still store for example the information in registering watch or metadata library.Want understanding how to gift the limits of variable application,.Want understanding how to gift the limits of object application,

The scenario that when also can write applied process to start or be being shut, should run.
...

ASP series lecture (seventeen) debug ASP script

No matter how your plan is exact, how experience is rich,Script mistake (the scenario that the likelihood is in Bug) to make your ASP server is carried at first cannot move correctly.Debug that is to say,Be searched namely and correct script error,Successful to developing with able-bodied ASP program it is very important.

Debugging aids of Microsoft script
Microsoft%26reg;Script Debugger is the debugging aids with a powerful function,The script that it can help you search a mistake quickly to be carried to the server has alternant test.Script Debugger and version of Windows Internet Explorer 3.0 or newer version work together.Through it,You are OK:

Run a server to carry script line by line.
When the server carries script to carry out,The value that opens variable of command window surveillance, attribute or array element.
In mark of time-out of specific travel setting,Hang a server to carry script (use debugging aids or script command) .
The process dogs when running a server to carry script.
Attention You can use debugging aids to examine scenario and find wrong place,But cannot edit script directly.Want to correct an error,After must editing crural naturalness with the editor, save,Run scenario again.

(this function cannot be used at Windows 95 or taller version.)

Enable debug
Before beginning to debug a server to carry script,You must configure Web server above all,Make its support ASP to debug.

After enabling Web server to debug,Can use the either method below to debug script:

Open Microsoft script to debug by hand implement,Debug ASP server to carry script.
Use Internet Explorer requests.asp document.If this file includes mistake or the stopping that add artificially,carry out a statement,So Microsoft script debugs a program to will be started automatically,Show this script,And point out wrong origin.
Script mistake
When debugging a server to carry script,The mistake that you may come up against all sorts of types.Among them certain mistake makes scenario cannot be carried out correctly, the program stops to carry out or return wrong result.

Solecism
Solecism is the mistake that often comes up against,It is bring about by incorrect script grammar.For example,Command spelling mistake or the parameter that transfer function are incorrect will produce a mistake.The script that solecism may bring about you cannot move.

The mistake when moving
The mistake when moving is script instruction of the script in carrying out a process tries to carry out impossible movement and be brought about.For example,One is included in the script below by zero except (a kind of illegal maths operation) function,The mistake when running generation:

%26lt;script Language = %26quot;VBScript%26quot; Runat = Server%26gt;
Result = Findanswer(15)
Document.write ("The Answer Is " %26Result)

Function Findanswer(x)
'This Statement Generates A Run-time Error.
Findanswer = X/0
End Function
%26lt;/script%26gt;
Must correct the error that causes the error when moving,When such ability make script is moving, be not interrupted.

Logic is wrong
Logical error may be potential normally with what detect hard.The logic that if because key in mistake or program logic,have,flow mistake causes is wrong,Script may move successfully,But the result of generation is wrong however.For example,One server carries script to plan to be worth list sort to,If should be used originally %26quot; %26lt; %26quot; the symbol is more numeric,But used however %26quot; %26gt; %26quot; symbol,Will return incorrect sort result so.

The mistake debugs a technology
The debugs a technology to search a mistake source that can use a variety of differring tests applied program.

Real time (Just-In-Time, JIT) is debugged
When a mistake when moving interrupted the execution of ASP script,Microsoft script debugs a program to be started automatically,File of indication.asp,The travel that points to statement finger to guide causes an error,Produce wrong message.This kind debugs means to call real time (JIT) is debugged,The computer carries out those who suspend a program.Must correct these errors with editor,The correction that saves place to do,Run scenario again next.

Breakpoint is debugged
When a mistake happens and finding wrong source very hard,Can use what set breakpoint beforehand to debug a method.Breakpoint suspends script be in specific group.There can be doubt place to install one or more different breakpoint in script,Use next debug implement the value of the variable that in correct script, installs or attribute.After correcting these errors when you,OK and cleared breakpoint so that your crural instinct moves uninterruptedly.

Debug a program to open script with Microsoft script please,Install breakpoint.Request this script with Web browser next.When the travel that breakpoint contains in carrying out script,The computer script that start debugs a program,And statement finger can point to go up in the travel that installed breakpoint.

Statement of VBScript Stop is debugged implement
Insert Stop statement through be before the share that server end has a problem in script,You also can add breakpoint in carrying script with the server that VBScript writes.For example,The ASP script below contains statement of a Stop,Before be being used, time-out is carried out:

%26lt;%
Dayvalue = 3
TheDay = WeekDayName(dayvalue)
Stop 'set Breakpoint Here.
Response.Write("Today Is " + TheDay)
%%26gt;
When foregoing script that you are requesting Web browser to use,Debug a program to start and show.asp file automatically,And the position that statement finger can indicate Stop statement.Stop statement is deleted in the.asp file that must remember be being used from consign.

Debug with statement of JScript Debugger
Should add breakpoint with Microsoft%26reg;The server that JScript writes carries script in,Debugger statement can be inserted before interrogative goes.For example,The script below contained Debugger statement,Every time when script is worth newly to circularly,Can interrupt carry out and start Microsoft script automatically to debug a program.

%26lt;%@ Language= %26quot;JScript %26quot; %%26gt;
%26lt;%
For (var Count = 1; Count %26lt;= 10; Count++ ) {
Var Eventest = Count%2;
Debugger / / Sets Breakpoint
If (eventest==0) {
Response.write(%26quot;Even Value Is %26quot; + Count + %26quot;%26lt;br%26gt;%26quot; )
}
}
%%26gt;
Debugger statement is deleted in remembering the.asp document that uses from consign please.

Attention Statement of not promiscuous Debugger and statement of JScript Break.During the program is carried out,Break statement exits current circulation only,Do not activation Microsoft script is debugged implement,The execution that also does not suspend a program.

Script debugs skill
Outside debugging a program except script,An a large number of time that debug skill well to also can reduce expenditure to go up in germ of analytic script mistake.Although major mistake is,bring about by the germ of clearly,But command spelling mistake or the logic of some kind of missing and variable, type and executive mistake is likely also because of not quite apparent germ be caused by.

...

ASP series lecture (ten six) visit database

ActiveX Data Objects (ADO) is a skill that be used easily and can add database visit patulously Web page.So that the script that can use ADO to write compact brachylogy receives the data source with the database with compatible Open Database Connectivity (ODBC) and compatible OLE DB repeatedly.If you are a logarithm,the scenario that has certain knowledge according to library join writes personnel,So you will discover ADO commands the statement masters not complex and easily.No less,If you are a personnel of experienced database process designing,You are affirming those who know ADO is advanced have nothing to do with the language gender and inquiry processing function.

Found file of ODBC DSN
Before founding database script,Must offer to make ADO fixed position, label and the way with database communication.The ODBC compatible database with fixed position of database driver use Data Source Name (DSN) and specific label,From Web application information the program passes a database.Below typical situation,DSN contains security of database configuration, user and fixed position information,And can get Windows NT to register a watch medium or the form of text file.

Through ODBC,The type of the DSN that you can choose to hope to found:User, system or file.User and memory of systematic DSN register a watch in Windows NT in.Systematic DSN allows all users to login to visit a database to specific server,And user DSN uses proper safe identification to limit the database link to specific user.File DSN is used at getting form from inside text file,The visit that provided many pairs of users,And pass document of duplicate DSN,Can transfer another server easily from a server.As a result of above reason,The give typical examples in this theme will use file DSN.

Through in Windows " begin " menu is opened " Control Panel " ,You can found the file that is based on DSN.Doubleclick " ODBC " icon,Choose next " file DSN " attribute page,Click " add " ,Choice database driver,Click next " next " .The DSN that deploys the database software that applies to you according to the directive from the back.

Configure the file DSN of database of Microsoft Access

In " establish new data source " in the dialog box,Choose from list casing " Microsoft Access Driver " ,Click next " next " .
The name of DSN file that keys in you,Click next " next " .
Click " finish " establish data source.
In " ODBC Microsoft Access 97 installs a program " in the dialog box,Click " choice " .File of database of choice Microsoft Access (*.mdb) ,Click next " affirmatory " .
Attention As a result of the reason of function and dependability,We recommend you to use to the utmost " client - server database engine " the data that configuration uses program drive by a kind of such Web,Processes of these Web application must satisfy 10 the user of above while visit.Although ASP can use the database with any compatible ODBC,But it is to be use client - server database and of the design,And passed strict test,These databases include Microsoft%26reg;SQL Server, Oracle.

ASP support shares file database (like Microsoft%26reg;Access or Microsoft%26reg;FoxPro) regard valid data as the source.Although a few give typical examples in ASP documentation are used,share file database,But our proposal uses engine of this kind of database at development only or deploy program finitely.The client that shares file database to cannot apply to the process of Web application that can satisfy high demand, high quality possibly well - server database.



Configure DSN of file of database of SQL Server

Attention If the database is stationed in,stay on long-range server,Contact with server administrator please,Get additional configuration information;The setting with the acquiescent ODBC that the process below uses SQL Server,The hardware that it may not apply to you is configured.

In " establish new data source " in the dialog box,Choose from inside list casing " SQL Server " ,Click next " next " .
The name that keys in DSN file,Click next " next " .
Click " finish " establish data source.
The name of the server that keys in moving SQL to serve a program, entry ID and password.
Be in " the new data source that establishs SQL Server " in the dialog box,Be in " server " the name that the server that includes database of SQL Server keys in in list casing,Click next " next " .
The way that chooses test and verify to log onto ID.
If want to choose test and verify of SQL server,Input an entry ID and password please,Click next " next " .
Be in " the new data source that establishs SQL Server " in the dialog box,The driver that installs setting of process of acquiescent database, memory and ANSI mark,Click next " next " .(should get detailed information,Click please " help " .)
In the dialog box (same name is " the new data source that establishs SQL Server " ) in,Choose a kind of character to change a method,Click next " next " .(detailed information,Click please " help " .)
In next dialog box (same name is " the new data source that establishs SQL Server " ) in,The choice logs onto a setting.
Attention Below typical situation,You can use a log to debug a database to visit a problem only.

In " ODBC Microsoft SQL Server installs a program " in the dialog box,Click " test data source " .If DSN is founded correctly," test result " the dialog box will point out the test is finished successfully.
Join of SQL Server and safe information
If you are being used at join in development,the ASP database of database of long-range SQL Server uses a program,Should consider the following issue:

Join plan - You can choose word of TCP/IP dowel joint and the method that name conduit to visit database of long-range SQL Server.Should use when naming conduit,Before establishing link because of,Database user must be affirmed by Windows NT,So proper to having only SQL Server visits the identity and may be rejected to visit in the user that there is account of user of Windows NT on this computer name conduit.As a kind of replacement scheme,The join of word of dowel joint of use TCP/IP can receive database server repeatedly directly,And the intermediate computer that need not name conduit through using.Because use word of TCP/IP dowel joint to join,can receive database Server repeatedly directly,Admit really through SQL Server so,The user can obtain a visit to counterpoise,And need not admit really through Windows NT.
Attention When receiving long-range database repeatedly word of dowel joint of use TCP/IP can improve performance.

Security - If you use SQL Server compositive or mixture safety is characteristic,And database of SQL Server is located in long-range server go up,Cannot use Windows NT to request / answer affirm.That is to say,Cannot request Windows NT / answer Id transmit to long-range computer,And can use primary status test and verify only,It offers user name and countersign information to undertake according to the user.
About the detailed information of this one theme,Consult please Http://www.microsoft.com/sqlsupport/
The technology of Microsoft SQL Server that go up supports a homepage.



Configure DSN of file of Oracle database

On the computer that should ensure software of Oracle user is wanted to found DSN by correctly installation above all.Detailed information,Be contacted with server administrator please or consult database software documentation.

In " establish new data source " in the dialog box,Choose from inside list casing " Microsoft ODBC For Oracle " ,Click next " next " .
The name that keys in DSN file,Click next " next " .
Click " finish " establish data source.
Password and input user name, server name,Click next " affirmatory " .
Attention DSN file uses.dsn patulous name,In be located in catalog of \Programs\Common Files\ODBC\Data Sources.

About the detailed information that establishs DSN file,Visit site of Microsoft ODBC Web please:Http://microsoft.com/odbc/ .

Join database
The first pace that visits database information is with the database the source establishs link.ADO offers Connection target,Can use this to the object is built and manage the link between applied process and ODBC database.Connection object has all sorts of attribute and method,Can use they are opened and shut a database to join,And issue inquiry request will replace news.

Should build a database to join,The example that should establish Connection target above all.For example,The script below establishs Connection target,Open a database to join then:

%26lt;%
'Create A Connection Object
Set Cn = Server.CreateObject("ADODB.Connection" )
'Open A Connection; The String Refers To The DSN
Cn.Open "FILEDSN=MyDatabase.dsn "
%%26gt;
Attention No matter be in equal-sign (still be before =) later,DSN string cannot include blank space.

Below this kind of circumstance,The Open method of Connection object cites the file that is based on DSN,Contain the position about the database and configuration information among them.Also need not cite DSN,Direct and explicit cite supply ID of source of program, data, user and password.

Carry out inquiry with Connection object
With the Execute method of Connection object,You can give out structuralization to inquire a language (SQL) inquires database source and retrieve a result.SQL is at the industrial standard language with database communication with,It has a lot of commands to be able to be used retrieve and replace news.

The Execute method that the script below uses Connection target gives out inquiry in form of jussive of SQL INSERT,This command inserts data specific database form.In the give typical examples below,In the database watch that script inserts name Jose Lugo the name to be Customers.

%26lt;%
'Define File Based DSN
StrDSN = "FILEDSN=MyDatabase.dsn "

'Instantiate The Connection Object And Open A Database Connection
Set Cn = Server.CreateObject("ADODB.Connection" )
Cn.Open StrDSN

'Define SQL SELECT Statement
StrSQL = "INSERT INTO Customers (FirstName, lastName) VALUES ('Jose' , 'Lugo') "
'Use The Execute Method To Issue A SQL Query To Database
Cn.Execute(strSQL)

%%26gt;
Attention The file that is based on string of DSN method is in equal-sign (=) around should not include blank space.

Besides command of SQL INSERT,You also can use SQL UPDATE and DELETE to the command is changed and delete database information.

With command of SQL UPDATE,You can change a database each project is worth in the watch.The FirstName field that the script below uses UPDATE to command field of every LastName in expressing Customers includes surname Smith to record is changed for Jeff.

%26lt;%
Set Cn = Server.CreateObject("ADODB.Connection" )
Cn.Open "FILEDSN=MyDatabase.dsn "
Cn.Execute "UPDATE Customers SET FirstName = 'Jeff' WHERE LastName = 'Smith' "
%%26gt;
Specific notes is deleted in wanting to be expressed from the database,Can use SQL DELETE to command.The travel that the script below deleted all surname Smith from inside Customers watch:

%26lt;%
Set Cn = Server.CreateObject("ADODB.Connection" )
Cn.Open "FILEDSN=MyDatabase.dsn "
Cn.Execute "DELETE FROM Customers WHERE LastName = 'Smith' "
%%26gt;
Attention When use SQL DELETE commands,Must be engaged in carefully.When using the DELETE that does not carry WHERE clause to command,It will delete all travel in the watch.Must include clause of SQL WHERE to appoint the exact travel that should delete.

Object of use Recordset handles a result
Although Connection object simplified to join the database is mixed,inquire the task,But Connection object still has a lot of inadequacy.Say exactly,The Connection object that retrieve and shows database information cannot be used at founding script;You must cut those who know to want to be made to the database to change truly,Just can use inquiry implementation change next.

To retrieving data, examination result, change a database,ADO offerred Recordset target.Its name place alludes no less than in that way,Recordset object has a lot of character that you can use,According to your inquiry limitation,Retrieve and show a group of database travel,Namely " record " .The position of the record that Recordset object holds inquiry to return,Allow you result of a progressively scanning.

According to the setting of attribute of type of pressing with a finger of Recordset object,You can roll and record newlier.Database finger can let you locate in a group of records specific.Pressing with a finger still is used at retrieving with servy record,Execute an operation on the foundation of these records next.Recordset object has a few property,The act that can be used at dominating index accurately,The capacity that increases to you are checked and update a result.For example,The type that you can use CursorType and index of setting of CursorLocation attribute,Return the result the client to carry applied program (normally as a result reservation is on database server) the last time that shows other user logarithm occupies a library is changed.

Retrieve a record
The data that a successful database application program uses Connection to the object establishs a link and use processing of Recordset object to return.Pass " harmonious " the specific function of two objects,You can develop the database application program that can implement any data processing tasks almost.For example,Executive SQL SELECT of object of upright script use Recordset commands the server below.The information that SELECT command retrieves a group to be based on inquiry to restrict.Inquiry also contains clause of SQL WHERE,The range that uses contractible inquiry.This in,The record that WHERE clause will inquire to limitation is the surname Smith that all Customers databases include in the watch.

%26lt;%
'Establish A Connection With Data Source
StrDSN = %26quot;FILEDSN=MyDatabase.dsn %26quot;
Set Cn = Server.CreateObject("ADODB.Connection" )
Cn.Open StrDSN

'Instantiate A Recordset Object
Set RsCustomers = Server.CreateObject("ADODB.Recordset" )

'Open A Recordset Using The Open Method
' And Use The Connection Established By The Connection Object
StrSQL = "SELECT FirstName, lastName FROM Customers WHERE LastName = 'Smith' "
RsCustomers.Open StrSQL, cn

'Cycle Through Record Set And Display The Results
' And Increment Record Position With MoveNext Method
Set ObjFirstName = RsCustomers("FirstName" )
Set ObjLastName = RsCustomers("LastName" )
Do Until RsCustomers.EOF
Response.Write ObjFirstName %26amp; %26quot; %26quot; %26amp; ObjLastName %26amp; %26quot;%26lt;BR%26gt; %26quot;
RsCustomers.MoveNext
Loop

%%26gt;
Notice,In the example in front,With will build object of database connective Connection and Recordset object to use this join to retrieve a result from inside the database.When the kind that needs accurately setting and database to build link place to use when you,This method is very useful.For example,The time that if you need to be appointed before join tries to fail,awaits,Need to use Connection object to install attribute.But,If you want to use ADO merely,acquiescent join attribute establishs link,The Open method that should use Recordset target goes establishing a link:

%26lt;%
StrDSN = %26quot;FILEDSN=MyDatabase.dsn %26quot;
StrSQL = "SELECT FirstName, lastName FROM Customers WHERE LastName = 'Smith' "
Set RsCustomers = Server.CreateObject("ADODB.Recordset" )

'Open A Connection Using The Open Method
'and Use The Connection Established By The Connection Object
RsCustomers.Open StrSQL, strDSN

'Cycle Through The Record Set, display The Results,
' And Increment Record Position With MoveNext Method
Set ObjFirstName = RsCustomers("FirstName" )
Set ObjLastName = RsCustomers("LastName" )
Do Until RsCustomers.EOF
Response.Write ObjFirstName %26amp; %26quot; %26quot; %26amp; ObjLastName %26amp; %26quot;%26lt;BR%26gt; %26quot;
RsCustomers.MoveNext
Loop
%%26gt;
When the Open method that should use Recordset target establishs a link,The security that must use Connection object to assure a link.

Improve inquiry with Command object
Through object of ADO Command,Can resemble carry out inquiry in that way with Connection object and Recordset object,Differ exclusively depend on using Command target you can go up in database source the preparation, value that inquire and uses a group what compile you to differ repeatedly will give out inquiry.The compiles inquiry good point of this kind of means is the time that you can reduce to weigh recrudesce to give recrudescent request place to need to existing inquiry to the greastest extent.Additional,The option of the variable portion of the inquiry that you carry before you still can be being carried out makes SQL inquiry keeps local and uncertain justice.

The trouble that the Parameter gather of Command object reduced you,Make you need not build inquiry afresh when giving out inquiry afresh every time.For example,If need to regular ground is based on the Web system of reserve detailed account newlier,supply mediumly with price information,Can inquire with the methodological predefine below:

%26lt;%
'Open A Connection Using Connection Object Command Object
'does Not Have An Open Method For Establishing A Connection
StrDSN = "FILEDSN=MyDatabase.dsn "
Set Cn = Server.CreateObject("ADODB.Connection" )
Cn.Open StrDSN

'Instantiate Command Object; Use ActiveConnection Property To Attach
'connection To Command Object
Set Cm= Server.CreateObject("ADODB.Command" )
Set Cm.ActiveConnection = Cn

'Define SQL Query
Cm.CommandText = "INSERT INTO Inventory (Material, quantity) VALUES (? , ? ) "

'Save A Prepared (or Pre-compiled) Version Of The Query Specified In CommandText
'property Before A Command Object's First Execution.
Cm.Prepared = True

'Define Query Parameter Configuration Information
Cm.Parameters.Append Cm.CreateParameter("material_type" , 200, , 255)
Cm.Parameters.Append Cm.CreateParameter("quantity" , 200, , 255)

'Define And Execute First Insert
Cm("material_type" ) = "light Bulbs "
Cm("quantity" ) = "40 "
Cm.Execute

'Define And Execute Second Insert
Cm("material_type" ) = "fuses "
Cm("quantity" ) = "600 "
Cm.Execute
%%26gt;
Examine the case above please,You will notice,Script repeats with different numerical value compose is built and give out a SQL to inquire,And mix without redefine send inquiry to arrive again database source.The amalgamative string that compiles inquiry to also can avoid SQL inquiry to cause with Command object and form variable problem.Especially,The problem that through using the Parameter of Command object gather can avoid to be concerned with the type of variable of definition string, date, time.For example,Include " ' " value of SQL inquiry may bring about inquiry to fail:

StrSQL = "INSERT INTO Customers (FirstName, lastName) VALUES ('Robert' , 'O'Hara') "
Notice,One is included in surnaming O'Hara " ' " ,It and those who represent data is use in key word of SQL VALUES " ' " conflict.Bind through will inquiring numerical value regards Command object as parameter calm,Can avoid this kind of problem.

Combine HTML form and database visit
The Web page that includes HTML form can make the user inquires a database remotely and retrieve specific information.With ADO you can found very simple script to gather user form information, found the database that defines oneself inquiry and return information the user.Object of use ASP Request,You can retrieve the information that inputs HTML form to incorporate these information in SQL statement.For example,The information that the script module below provides HTML form inserts form in.This script gathers user information with the Form gather of Request object.

%26lt;%
'Open A Connection Using Connection Object. The Command Object
'does Not Have An Open Method For Establishing A Connection
StrDSN = "FILEDSN=MyDatabase.dsn "
Set Cn = Server.CreateObject("ADODB.Connection" )
Cn.Open StrDSN

'Instantiate Command Object
'and Use ActiveConnection Property To Attach
'connection To Command Object
Set Cm= Server.CreateObject("ADODB.Command" )
Set Cm.ActiveConnection = Cn

'Define SQL Query
Cm.CommandText = "INSERT INTO MySeedsTable (Type) VALUES (? ) "

'Define Query Parameter Configuration Information
Cm.Parameters.Append Cm.CreateParameter("type" , 200, , 255)

'Define And Execute Insert
Cm("type" ) = Request("SeedType" )
Cm.Execute

%%26gt;
Manage database link
Design can the Web database of withstand test uses a program (the process of online shopping application that serves for thousands of client for example) the biggest challenge,Depend on how managing a database to join reasonably.Open and maintain a database to join,When although be in,be being transmitted without information,The resource that also can expend database server badly and may cause join sex problem.The program of application of Web database with good design will reclaim to because the network jams,can be compensated the delay that cause.

Make join overtime
Unexpected growth of the activity may make database server becomes very awakward,A large number of addition build database connective time.The result is,The too chief function that joins delay time will reduce a database.

With the ConnectionTimeout of Connection object,You can be restricted abandon joining the attempt erupts simultaneously the time that before giving erroneous information, applied process awaits.For example,The script below installs ConnectionTimeout attribute,20 second awaits before cancelling join to try:

Set Cn = Server.CreateObject("ADODB.Connection" )
Cn.ConnectionTimeout = 20
Cn.Open "FILEDSN=MyDatabase.dsn "

Acquiescent ConnectionTimeout attribute is 30 second.

Attention Incorporating ConnectionTimeout attribute before database application process,Must ensure join offers program and data source to support this attribute.

Share join
The performance that often be built and suspends database of database connective Web to apply a program to may reduce database server.ASP supports those who use ODBC 3.5 to share characteristic and effective managing to join.Join is shared maintain the user that the database that open joins and administration differs to share this join,Count in order to maintain its function and the link that reduce leisure.To each join request,The join that whether leisure exists in joining the pool decides a pool above all.If exist,Join pool returns join and not be the new link that establishs a database.

In if hope to join ODBC driver join,be being shared,The CPTimeout attribute that must configure database driver and registers driver of the setting in the watch in Windows NT.Disconnect when ODBC when join,Join is stocked in the pool,is not to be disconnected.The time length that CPTimeout attribute decides to the join in join pool is withheld.If be in the pool,the time that the time that join retains sets than CPTimeout grows,Join will be shut and delete from inside the pool.The acquiescent value of CPTimeout is 60 second.

The registers watch key to install CPTimeout selectively attribute that you can install through be being founded as follows,The join pool that enables driver of database of specific ODBC thereby:


\HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\driver-name\CPTimeout = Timeout
(REG_SZ, units Are In Seconds)

For example,The key below decides the overtime setting of the join pool of driver of SQL Server for 180 second (3 minute) .

\HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\SQL Server\CPTimeout = 180
Attention Below acquiescent circumstance,Through be CPTimeout setting 60 second,Web server will activation the join pool of SQL Server.

Use the connection that cross a page
Although you are OK,use the connection that cross a page through storing the join of the Application object of ASP repeats,But,Make join maintains from beginning to end opening is needless,Also did not make full use of the advantage of join pool.If a lot of users need to join same a process of application of ASP database,A good method is,In the Application object ASP of park of string of the join that cross a page,Repeat service data library to join.For example,Join string can be appointed in the process of Application_OnStart incident in Global.asa file,The script place of following faces is shown:


Application.lock
Application("ConnectionString" ) = "FILEDSN=MyDatabase.dsn "
Application.unlock

Next,Write in the ASP file that visits a database in each:

%26lt;OBJECT RUNAT=Server ID=cn PROGID= %26quot;ADODB.Connection %26quot;%26gt;%26lt;/OBJECT%26gt;
The example that wants to establish join target,Use the following script please:

Cn.Open Application("ConnectionString" )
To the join that open,The following script can be written in page end,Close link:

Cn.Close
In individual user need repeats use circumstance of the connective that cross a page to fall,Link of object of use Session is nicer than using Application target.
Close link
Want to use join pool better,Should shut a database as soon as possible to join.Below acquiescent circumstance,After be being carried out when script,Join will be stopped.Shut its when needing link no longer,Ask with respect to what can reduce pair of database servers and can make other user can use this connection.

The Close method that can use Connection target stops the join between Connection object and database.The script below opens join,Shut its next:

%26lt;% StrDSN = %26quot;FILEDSN=MyDatabase.dsn %26quot;
Set Cn = Server.CreateObject("ADODB.Connection" )
Cn.Open
Cn.Close
%%26gt;

 
...

ASP series lecture (ten five) form of use HTML

Object of use ASP Request,You can found a script with simple and powerful function to collect and process data of HTML form.In this theme,You will learn how to found basic form to handle script not only,And a few useful technologies that still will obtain the form information that is used on server of Web of test and verify and user browser.

About HTML form
HTML form is to collect the means with Web the most commonly used information,Be user interface is offerred to accuse on Web page the permutation that special HTML labels.Text casing, pushbutton and answer choose casing is a model to accuse,These accusing make user and implementation of Web page alternant,And submit information give Web the server.

The HTML give typical examples below produces a form,In form,The button that the user can input full name, age and includes to submit these information Web server.This form also included to accuse implicitly (Web browser does not show) ,Can accuse with this pass additional information to Web browser.

%26lt;FORM METHOD= %26quot;POST%26quot; ACTION= %26quot;myfile.asp%26quot; %26gt;
%26lt;INPUT TYPE= %26quot;text%26quot; NAME= %26quot;firstname %26quot;%26gt;
%26lt;INPUT TYPE= %26quot;text%26quot; NAME= %26quot;lastname%26quot; %26gt;
%26lt;INPUT TYPE= %26quot;text%26quot; NAME= %26quot;age%26quot; %26gt;
%26lt;INPUT TYPE= %26quot;hidden%26quot; NAME= %26quot;userstatus%26quot; VALUE= %26quot;new%26quot; %26gt;
%26lt;INPUT TYPE= %26quot;submit %26quot; VALUE= %26quot;Enter%26quot; %26gt;
%26lt;/FORM%26gt;
Treat the form that ASP inputs
When form submits information to Web server,The Web browser of the user requests to use HTML %26lt;FORM%26gt;The.asp file that the place of ACTION attribute of mark appoints (in the example in front,This file is called Myfile.asp) ..asp file included processing form to be worth (if show,inquire information from the database) script.

Can collect the cost of HTML form with.asp file through three kinds of ways

.htm file of the static state can include a form that its numeric mail sends.asp the document.
The form that.asp file can found to give another.asp the file its information post.
The form that.asp file can found to give oneself its information post,The file that includes this form namely.
The mode of operation of before two methods is identical,When form and gateway program are alternant,Except ASP,Can include read the command that take and answers user choice.

Found to include form to define and the.asp file that deferent information gives oneself is more complex,But the method that is the processing form that has very strong function however.This one process demonstrates in input of proof list case.

Obtain form input
Object of ASP Request offerred two kinds of gather,Simplified to retrieve greatly add the task of the form information on URL request.

QueryString assembles
The value that QueryString gather gets the text at the back of the interrogation that serves as the URL that follows in the request to deliver Web server.Through using method of HTTP GET or handiwork to add the cost of form URL,The value of form can be added to be after the URL of the request.

For example,If foregoing form give typical examples use GET method (ACTION = "GET" ) and the user is keyed in Jeff, Smith and 30,So the URL request below will be sent to send a server:

Http://scripts/Myfile.asp? Firstname=Jeff%26lastname=Smith%26age=30%26userstatus=new
Myfile.asp includes the form below to handle script:

Hello, %26lt;%= Request.QueryString(%26quot;firstname%26quot; ) %%26gt; %26lt;%= Request.QueryString(%26quot;lastname%26quot; ) %%26gt; .
You Are %26lt;%= Request.QueryString(%26quot;age%26quot; ) %%26gt; Years Old.


%26lt;%
If Request.QueryString("userstatus" ) = %26quot;new User%26quot; Then
Response.Write "This Is Your First Visit To This Web Site! Response.Write "This Is Your First Visit To This Web Site!!
End If
%%26gt;
Below this kind of circumstance,The Web browser that Web server will return the text below to give an user:

Hello, jeff Smith. You Are 30 Years Old. This Is Your First Visit To This Web Site!
QueryString gather has an optional parameter,A when can use a visit to show the many values in asking main body are medium.Also can use Count attribute to calculate the occurrence frequency of the value of a special kind.

For example,The list casing that form includes a many item can submit the request below:

Http://list.asp? Food=apples%26food=olives%26food=bread
You also can use the command below to be counted to many estimation:

Request.QueryString("food" ).Count
If want to show the type of many values,List.asp should include the script below;

%26lt;%Total = Request.QueryString(%26quot;food%26quot; ).Count%%26gt;
%26lt;%For I = 1 To Total%%26gt;
%26lt;%= Request.QueryString(%26quot;food%26quot; )(i) %%26gt;%26lt;BR%26gt;
%26lt;%Next%%26gt;
Afore-mentioned script will show:
Apples
Olives
Bread
Form assembles
Deliver long and complex form when server of Web of whereaboutldirection of method of use HTTP GET when the value,Cease may missing letter.The length that apt of most Web server controls URL strictly to inquire string,So that use GET method,deferent expatiatory form value is cut off.If you need to send a large number of message from form to Web server,Must use method of HTTP POST.This law is used at form data is being transmitted in text of HTTP request,And a number of sent character is OK and infinite much.The Form rally that also can use target of ASP Request retrieves the value that sends with POST method.

Form gather and the way with numeric memory of QueryString gather are same.For example,If the user is used,grow string of name stuff form,You can retrieve these names with the script below:

%26lt;% For I = 1 To Request.Form.Count %%26gt;
%26lt;% =Request.Form(%26quot;names%26quot; )(i) %%26gt;
%26lt;% Next %%26gt;
Proof list case is inputted
Before a good form processing scenario is processing data,Should the information of form of transcendental card input is significant.Script of test and verify can examine the information kind that the user inputs form is right.For example,If your Web site includes a form,This form allows information of user computation finance affairs,So before handling a result,The user inputted numeric information really and needing test and verify is not text.

The method that a form of very convenient test and verify inputs is the form that founds to pass information to oneself.Below this kind of circumstance,.asp file includes the form that can get information.For example,The script below comes through passing information to oneself whether did user of test and verify input numerical value in field of "age" form:

%26lt;% If Isnumeric(Request.QueryString(%26quot;Age%26quot; )) Then %%26gt;
%26lt;p%26gt;Hello, your Age Is %26lt;%=Request.QueryString(%26quot;age%26quot; )%%26gt;
%26lt;%Else %%26gt;
%26lt;p%26gt;Please Enter A Numerical Age.
%26lt;%End If %%26gt;

%26lt;FORM METHOD= %26quot;POST %26quot; ACTION= %26quot;verify.asp %26quot; %26gt;
Name: %26lt;INPUT TYPE= %26quot;text%26quot; NAME= %26quot;Name%26quot; %26gt;
Age:%26Nbsp; %26lt;INPUT TYPE= %26quot;text%26quot; NAME= %26quot;Age%26quot; %26gt;
%26lt;INPUT TYPE= %26quot;submit%26quot; VALUE= %26quot;Enter %26quot;%26gt;
%26lt;/FORM%26gt;
In this example,Script also is in the file of same Verify.asp that includes form.Form conveys to oneself through Verify.asp is being appointed in ACTION attribute information.

You also can found a client to carry script to examine whether did the user input significant information.User of test and verify hints to the user besides rapidder ground in the input on Web browser form outside the mistake,The network flow that still can reduce Web server.On the Web browser that the script below runs in the user,Before submitting information Web server,Information of user of test and verify.

%26lt;SCRIPT LANGUAGE= %26quot;VBScript%26quot; %26gt;
%26lt; ! - -
Sub BtnEnter_OnClick
Dim TheForm
Set TheForm = Document.MyForm
If IsNumeric(TheForm.Age.Value) Then
TheForm.submit
Else
Msgbox "Please Enter A Numerical Age. Msgbox "Please Enter A Numerical Age..
End If
End Sub
/ /- - %26gt;
%26lt;/SCRIPT%26gt;

%26lt;FORM METHOD= %26quot;POST%26quot; NAME= MyForm ACTION= %26quot;myfile.asp %26quot; %26gt;
Name: %26lt;INPUT TYPE= %26quot;text%26quot; NAME= %26quot;Name%26quot; %26gt;
Age:%26Nbsp; %26lt;INPUT TYPE= %26quot;text%26quot; NAME= %26quot;Age%26quot; %26gt;
%26lt;INPUT TYPE= %26quot;button%26quot; NAME= %26quot;btnEnter %26quot; VALUE= %26quot;Enter %26quot;%26gt;
%26lt;/FORM%26gt;
...

ASP series lecture (ten four) include a file

SSI instruction provides the means that inserts the content of a file another file before Web server is handled for the user.The #include that ASP uses this one mechanism only dictates.A file should be inserted in.asp file,Use the grammar below:

%26lt; ! - - #include Virtual | File = "filename "- -%26gt;
The type that Virtual and directive of File key word use the method that includes this file,The method that Filename is the file that you consider to include and name.

The file that be included does not ask special file is patulous renown;But,To be included the file gifts so that.inc patulous name distinguishs with photograph of other type file it is a good process designing convention.

Key word of use Virtual
Key word of use Virtual points out method begins at fictitious catalog.For example,If one is named to be the file of Footer.inc to belong to,the name is / the fictitious catalog of Myapp,Criterion the group below will insert the content of Footer.inc in including this file:

%26lt; ! - - #include Virtual = "/myapp/footer.inc "- -%26gt;
Key word of use File
Directive of key word of use File uses opposite method.The list that opposite way begins to include a file at containing this.For example,If your file is located in in catalog Myapp,And file Header1.inc is in Myapp\Headers,In the file that inserts Header1.inc below to you soon:

%26lt; ! - - #include File = "headers/header1.inc "- - %26gt;
Notice,The method to Headers/header1.inc of the file that be included is opposite at including a file;If include the script of #include statement to be absent / in Myapp catalog,So this statement will be not effective.

If government serves in Internet implement medium " enable superstratum catalog " option by pitch on,Also can use File key word and. . / grammar includes father catalog to go up namely the file in a catalog.

The position of the file that be included
The file that be included can be in a certain catalog inside your Web site,Also can be besides your Web site.Normally,In the catalog that you should make the file that be included is located in Web site.If a file that be included is located in inside your Web site,Request to include a file next time when the browser when,The change that will show pair of files that be included.But,Besides the Web site that if be included,the file is located in you,When till ASP application the program is started afresh or Web server is started afresh,Body of ability of this kind of change comes out now.ASP detects in applying a program to name a space (below the initial list that using a program) any changes that include a file.

Include a file:Hint and warn
A file that be included also can include other files.If #include instruction did not bring about a loop,File of a.asp can include for many times same a file.For example,If file First.asp includes file Second.inc,Criterion Second.inc scarcely can include First.asp again.A file also cannot include oneself.ASP detects this kind of loop or nest mistake,Produce a wrong message when detecting,The.asp file that stops processing to be requested at the same time.

ASP includes a file before executive script commands.Because of this,The name that cannot found the file that be included with script command.For example,The script below will cannot open Header1.inc,Because ASP can allocate a file in it,#include is carried out to dictate first before the name gives variable Name.

%26lt; ! - - This Script Will Fail- - %26gt;
%26lt;% Name=(header1 %26amp; %26quot;.inc%26quot; ) %%26gt;
%26lt; ! - - #include File= %26quot;%26lt;%= Name %%26gt; %26quot;- - %26gt;
Script commands and the process must be included completely in script delimiter accord with %26lt;% and %%26gt;, %26lt;SCRIPT of HTML mark%26gt;With %26lt;/SCRIPT%26gt;Or %26lt;OBJECT of HTML mark%26gt;With %26lt;/OBJECT%26gt;In.That is to say,Cannot include in a.asp a script is opened in the file delimiter accord with,Just shut this in a file that is included next delimiter accord with;Script or script command must be a complete unit.For example,The script below will not move:

%26lt; ! - - This Script Will Fail- - %26gt;
%26lt;%
For I = 1 To N
Statements In Main File
%26lt; ! - - #include File= "header1.inc "- - %26gt;
Next
%%26gt;
The script below will move normally:

%26lt;%
For I = 1 To N
Statements In Main File
%%26gt;
%26lt; ! - - #include File= "header1.inc "- - %26gt;
%26lt;% Next %%26gt;
...

ASP series lecture (ten three) convey to the browser script

Although ASP basically is used,handle a server to carry script,Still can use it to generate the client that handles by client browser to carry script to expand its effectiveness.It is OK to convey to command to the script of the browser through combination write a server to carry script.

Upright script mixes the client that rises by draw together of HTML annotate through combination by delimiter the server that accord with draw together rises carries script to be able to accomplish this:

%26lt;SCRIPT LANGUAGE= %26quot;VBScript %26quot;%26gt;
%26lt; ! - -
Client Script
%26lt;% Server Script %%26gt;
Client Script
%26lt;% Server Script %%26gt;
Client Script
. . .
- - %26gt;
%26lt;/SCRIPT%26gt;
This function of use script language,You can establish exciting applied program.E.g. ,The subprogram that the script below will create the client scenario that runs on the Web browser of the user.

%26lt;%
ServerTime = Time
ServerDate = Date

For I = 1 To 4
Randomize
GreetCondition = Int(rnd * 3)
%%26gt;

%26lt;SCRIPT LANGUAGE= %26quot;VBScript%26quot; %26gt;
%26lt; ! - -

Sub ServeInfo%26lt;%= I %%26gt;()
Select Case %26lt;%= GreetCondition%%26gt;
Case 0
Msg = "Hello, the Time Is %26lt;%= ServerTime %%26gt; . The Time Is <%= ServerTime %> ..
Case 1
Msg = "Welcome! Today's Date Is %26lt;%= ServerDate %%26gt; . Today's Date Is <%= ServerDate %> ..
Case 2
Msg = "Hi, the Time Is %26lt;%= ServerTime %%26gt;And The Date Is %26lt;%= ServerDate %%26gt; .
End Select
Document.Write Msg
End Sub

ServeInfo%26lt;%= I %%26gt;()

/ /- - %26gt;
%26lt;/SCRIPT%26gt;

%26lt;br%26gt;

%26lt;%
Next
%%26gt;
In the script of above,ASP retrieves time and date information on the server,Generate the subprogram that moves on the Web server of the user through circulating a few times next.The greeting that program of every client terminal puts forward to choose randomly,Indication time and date information.

This kind of script can expand,For example,Will configure Information Retrieval and refer appointed client to carry script or package,If ActiveX accuses.Use this kind of script neatly write skill,The rate that can accelerate Web to the server is handled and return user information to request likewise.

...

ASP series lecture (ten two) send content to the browser

When handling ASP script,Any doing not have include in ASP delimiter accord with or %26lt;SCRIPT%26gt;The text in mark or graph will be returned by simple ground browser.Can show through using Response target the ground sends content to the browser.

Send content
Should content from ASP delimiter accord with interior or process hair send a browser,The Write method that can use Response target.For example,Whether can have the statement below visited this page according to the user and send different complimentary signal:

%26lt;%
If FirstTime = True Then
Response.Write %26quot;%26lt;H3 ALIGN=CENTER%26gt;Welcome To The Overview Page%26lt;/H3%26gt; %26quot;
Else
Response.Write %26quot;%26lt;H3 ALIGN=CENTER%26gt;Welcome Back To The Overview Page%26lt;/H3%26gt; %26quot;
End If
%%26gt;
In the process exterior,Need not use Response.Write to remand content user.Be absent script is delimiter the content of accord with interior is sent a browser by direct hair,The browser changes its pattern and show.For example,The script process below and the script output above are identical:

%26lt;H3 ALIGN=CENTER%26gt;
%26lt;% If FirstTime Then %%26gt;
Welcome To The Overview Page.
%26lt;% Else %%26gt;
Welcome Back To The Overview Page.
%26lt;% End If %%26gt;
%26lt;/H3%26gt;
When you output returns a need general or very when adding a statement to the middle of text of existing HTML conveniently,Can use mixture script command and HTML.Do not want to use when you delimiter accord with space a statement or when you want to found the string that returns a browser,Can use Response.Write.For example,But the string that compose builds a text version,The group that establishs form with the value that remands from watch of a HTML:

Response.Write %26quot;%26lt;TR%26gt;%26lt;TD%26gt;%26quot; %26amp; Request.Form(%26quot;FirstName%26quot; ) _
%26amp; %26quot;%26lt;/TD%26gt;%26lt;TD%26gt;%26quot; %26amp; Request.Form(%26quot;LastName%26quot; ) %26amp; %26quot;%26lt;/TD%26gt;%26lt;/TR%26gt; %26quot;

Set the kind of content
When Web server returns the file the browser,The type of the content that can tell a browser to be included in the file at the same time.This makes the browser can decide to whether it itself can show a file or must call another application program.For example,If network server returns form of Microsoft Excel,Criterion the carbon that the browser must call Microsoft Excel shows this page.Web server carries the patulous name the file map identifies file type to watch of MIME type.

The content that the ContentType property that can use Response target gives an user to send sets string of type of HTTP content.For example,The command below sets content kind for passageway definition:

%26lt;% Response.ContentType = %26quot;application/x-cdf%26quot; %%26gt;
About the detailed information of the passageway,Consult please in this theme " establish dynamic channel " .

Other general content types are Text/plain (content is returned and be being used at serving as text is not the HTML sentence that already explained) , Text/gif (use at GIF image) with Video/quicktime (use at Apple QuickTime%26reg;The film of the format) .The MIME type of a standard has been defined,Additional,Web server or Web browser back MIME kind.The server of Microsoft Web that wants to examine you backs what content kind,Can use Internet to serve government implement the attribute page of the Web site that opens you,Click " HTTP caption " option gets stuck,Click next " file type " option gets stuck.

Weigh directional browser
Can weigh the browser with Redirect method directional to another URL,is not send content the user.For example,The applied order that whether if you want to affirm an user,already entered you from the homepage,So that can receive ID of a client,Can examine whether do they have number of client ID;If do not have,Can weigh its directional to the homepage.

%26lt;%
If Session("CustomerID" ) = 0 Then
Response.Redirect "homepage.asp "
End If
%%26gt;
Unless buffer has been opened,Otherwise,Before any content or caption return a browser,You must weigh directional browser.Put Response.Redirect statement in the coping of the page and %26lt;HTML%26gt;Can ensure before mark return a browser without any content.If be after the content that returns a browser or caption,use Response.Redirect,Will see a wrong message.

If in the intermediate use Response.Redirect of the page,Use its and Response.Buffer property together please,The part below will undertake explanatory.

Amortize content
Below acquiescent circumstance,Web server returns HTML and the script processing result when handling ASP page.But,The Buffer attribute that you can set Response target so that before sending any content to the user,All server script that handle a page to go up first command.

A certain bits in can using amortize technology to handle a process in the page certainly,And the content before you do not want to nod this sends an user.The Redirect method that also can use Response target weighs the user directional to another page,The content hair that cleared buffer will differ gives the Clear method that perhaps uses Response target the user.The example below used above two kinds of methods.

%26lt;%
'Turn On Buffering. This Statement Must Appear Before The %26lt;HTML%26gt;Tag.
Response.Buffer = True %%26gt;
%26lt;html%26gt;
%26lt;body%26gt;
.
.
.
%26lt;%
If Request("FName" ) = "" Then
Response.Clear
Response.Redirect "/samples/test.html "
Else
Response.Write Request("FName" )
End If
%%26gt;
%26lt;/body%26gt;
%26lt;/html%26gt;
Before also can using Response.Buffer to avoid Web server to revise HTTP caption in script, return its.Some attribute and method,For example Response.Expires and Response.Redirect can revise HTTP caption.

Buffer attribute should be installed in script and when calling Flush method,The server requests the Keep-Alive that maintains an user to give out.Such script writes nurturance the habit is beneficial to the performance that improves a server,Because of,The server need not request to establish new link for each user (assume server, user supports Keep-Alive to ask with any acting servers) .But,A of this kind of method potential adverse factor is:Before the user handles all script of current Asp file,Buffer does not show any give response user.More complex to be being mixed longerly scenario,The user should be forced possibly to await ability of very long period of time to see this one page.

Below acquiescent circumstance,Buffer uses a program to ASP is shut.Can use Internet to serve government implement for whole ASP applied process opens buffer.

Allow page of acting server cache
Through acting server,Applied process can send a page to give an user.Acting server replaces user browser to request a webpage from Web site.So that page of HTML of acting server cache is identical the repetition of the page requests to be able to return a browser effectively quickly.Acting server executes a request and cache webpage,The negative charge that reduces network and Web server.

Although cache is right HTML page very can lucky travel,But the ASP page that makes news to including trends fares badly.For example,Prices of report stock market or the inventory need that indicate a large number of business provide instant information.The information a hour ago is to be told at present very inaccurate.If apply a program to return the individual's information,For example,From the homepage of the definition,The individual information that hopes the user cannot see another user.

Below acquiescent circumstance,ASP commands acting him server cannot page of cache ASP (although cache image, bitmap, small-sized applying program,The reference that goes up with other cache page) .Can use Response.CacheControl attribute to install cache to control field of HTTP caption to allow cache some page.The acquiescent value of Response.CacheControl is string "Private" ,It avoids acting server cache this page.Should allow cache,Can be setting of field of cache control caption Public:

%26lt;% Response.CacheControl = %26quot;Public%26quot; %%26gt;
Before the content of any pages is sent because of,HTTP caption must be sent browser or acting server,So,Response.CacheControl attribute can be installed before any HTML label or use Response.Buffer cache this page.

The one part that field of cache control caption is norms of HTTP 1.1.On the acting server that supporting HTTP 1.0 only cannot page of cache ASP,Because do not have due caption field,send.

Avoid browser cache page
The standards that each browser version has itself will set whether cache page.Should avoid page of browser cache ASP,Can use Response.Expires setting to expire caption:

%26lt;% Response.Expires = 0 %%26gt;
The value forces cache page to expire for 0.Before any pages are sent because of,HTTP caption must be sent a browser,Can be through putting Response.Expires property so before HTML mark or use Response.Buffer cache this page.

Establish dynamic channel
Internet Explorer 4.0 has a new character,The Web page that personnel of Web program can use this attribute to will contain public theme merges into a passageway.In the browser,The passageway is shown to be on passageway caption column;The user visits a passageway through clicking icon.Passageway backstage is updated automatically;It is OK that the user need not visit a site hold newest page up and down in his browser.The fast and direct access that the passageway provided to browse a group of relevant Web pages for the user,And these Web pages are automatic update.

Use ASP,An option that can write script to collect an user,Establish a channel dynamicly next.The passageway defines a file (the organization that.cdf) built passageway content and order.The command in.cdf file uses as identical as HTML mark grammar,Master in order to facilitate and generate from inside script.When writing ASP script to found a passageway to define a file,Script uses.cdx patulous name.When ASP reads the document that takes to be patulous name with.cdx,Will send kind of Application/x-cdf content automatically,It tells a browser with the passageway the definition explains byte.If do not use.cdx to make patulous name,Criterion script must use Response.ContentType handiwork to be content type setting Application/x-cdf.

It is one concerns the give a demonstration that how uses a channel below.The user of requirement of HTML form below chooses a passageway.When referring,The definition that this form attune establishs a channel with the script of.cdx file.

%26lt;P%26gt;Choose The Channels You Want. %26lt;/P%26gt;
%26lt;FORM METHOD= %26quot;POST%26quot; ACTION= %26quot;chan.cdx%26quot; %26gt;
%26lt;P%26gt;%26lt;INPUT TYPE=CHECKBOX NAME=Movies%26gt;Movies
%26lt;P%26gt;%26lt;INPUT TYPE=CHECKBOX NAME=Sports%26gt;Sports
%26lt;P%26gt;%26lt;INPUT TYPE= %26quot;SUBMIT%26quot; VALUE= %26quot;SUBMIT%26quot; %26gt;
%26lt;/FORM%26gt;
The script basis in Chan.cdx and the value that request referred form one case found a passageway to define.

%26lt;% If Request.Form(%26quot;Movies%26quot; ) %26lt;%26gt;%26quot;%26quot; Then %%26gt;
%26lt;CHANNEL%26gt;
Channel Definition Statements For The Movie Pages
%26lt;/CHANNEL%26gt;
%26lt;% End If %%26gt;

%26lt;% If Request.Form(%26quot;Sports%26quot; ) %26lt;%26gt;%26quot;%26quot; Then %%26gt;
%26lt;CHANNEL%26gt;
Channel Definition Statements For The Sports Pages
%26lt;/CHANNEL%26gt;
%26lt;% End If %%26gt;
Send a document to the server
The browser can use process of application of Posting Acceptor to send the document Web server.When the file holds on Posting Acceptor,The field of URL-encoded form that will send the file name that lists each are received and position.The URL that can handle post is added in script,The file carries to call ASP script to handle these field names on this script.For example,Can write a script,The tag that carries a file automatically and position send E-mail to give a system the manager.

...
« 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 »