Starting a Login ASP
|Introduction. Last page we started on the Response class. We got into some depth about the Write method, but we will work with most of the rest of the properties or methods that are more typically used. I've reproduced the overview table again in this page, below.|
|Write||This sends data to the client's web browser to be displayed as part of a web page.|
|Buffer||This can be true or false depending on whether you want the results to be accumulated into a buffer and sent all at once to the client.|
|Clear||Assuming that buffering is turned on or true, this will cause the buffer to be wiped out.|
|Flush||Assuming that buffering is turned, this will cause the buffer to be wiped out but it first sends the contents of the buffer to the client.|
|End||This terminates execution of a script. If Response.Buffer = True then the contents of the buffer are first sent to the client.|
|Redirect||This will redirect a user to another page.|
|Next, we will develop an example that will illustrate
more of the aspects of the remaining methods and properties. We
have not yet covered how to handle communicating with the user so the
login ASP will be missing some important aspects, but it will be very
useful to illustrate some of the other features of the Response class.
Developing a Login ASP. The following ASP uses a buffer to accumulate the results of the ASP before sending a response to the client/user. It also redirects the user to a members only section if the ASP contains a valid password. If the ASP doesn't contain a correct password then the user is given an appropriate message and the ASP ends after having sent the contents of the buffer to the client/user. Unfortunately, we haven't yet covered how to collect the password from the user and make use of that within an ASP, so we need to rely on a built-in password. Obviously, this defeats the purpose of a real login ASP, but it will illustrate several features of the Response class.
First you need to develop a page called members.html that has the following content and upload it to your root web.
Well let someone else get near you!
You're definitely a member.
|Now you should copy in the following code and save it as Login.asp. Then you should upload it to your root web and go to the page.|
|<%@ Language=VBScript %>
<% Option Explicit %>
<% Response.Buffer = True %>
Dim boolPassMatch, strRealPass, strEnteredPass
strRealPass = "kilroy22"
strEnteredPass = "kilroy22"
boolPassMatch = (strEnteredPass = strRealPass)
If boolPassMatch Then
|After the ASP executes you should get the following image on your screen because you have been redirected to members.html.|
|After having executed this version of the Login.asp you should modify strEnteredPass so that it is incorrect. For example, you can make it "kilroy21". Now you should get the following screen.|
|During class we will discuss more about the meaning of
While there are a number of other aspects of the Response class we could discuss, such as caching, we will leave these to more appropriate stages in our development.