<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Monie Studios &#187; asp</title>
	<atom:link href="http://www.moniestudios.com/tag/asp/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.moniestudios.com</link>
	<description>So much to learn, so little time!</description>
	<lastBuildDate>Sat, 21 Aug 2010 04:59:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>5 Tips To Speed Up Your ASP Page &#8211; P2</title>
		<link>http://www.moniestudios.com/tutorials/asp_speed_p2/</link>
		<comments>http://www.moniestudios.com/tutorials/asp_speed_p2/#comments</comments>
		<pubDate>Mon, 08 Jun 2009 04:06:28 +0000</pubDate>
		<dc:creator>Monie</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[asp]]></category>

		<guid isPermaLink="false">http://www.moniestudios.com/?p=403</guid>
		<description><![CDATA[PART @: This quick tips will teach you how you can get the best out of your ASP application. Part one will be discussing about some basic tips and part two will be covering in a lot more detail.]]></description>
			<content:encoded><![CDATA[<p>On the <a class="mw" href="http://www.moniestudios.com/asp_speed_p1/">Part 1</a> of this article, I&#8217;ve talked about <strong>5 tips to speed up your ASP page</strong>. The second part of this article will be much more interesting as I&#8217;ll be talking yet another 5 more great tips for your asp needs!</p>
<h2>6. Be Specific When Using The Request Object Collections.</h2>
<p>When a browser asks for a page from a server, it is called a request. The ASP Request object is used to get information from the user. This code is what normally programmers do:</p>
<pre class="brush: vb;">
&lt;%
	Dim name
	name = Request(&quot;name&quot;)
%&gt;
</pre>
<p>The request object has <strong>FIVE COLLECTION</strong> plus a default collection. The default collection is what you are seeing above. The other collections are:</p>
<ul>
<li>QueryString</li>
<li>Form</li>
<li>Cookies</li>
<li>ClientCertificates</li>
<li>ServerVariables</li>
</ul>
<p>Every ASP programmer is familiar with these collections. They are pretty much the most crucial tools available in the Request object. They allow you to gain access to the client&#8217;s request information.<br />
When you do a call to the default Request collection, each of the sub collections are searched in that following order.</p>
<p>The process stops when the first match is found. If you&#8217;re passing a lot of information between pages, using the default collection to get inputs can result in slowdowns, especially if you&#8217;re looking for servervariables that way. What I usually do is use the default collection if I am looking for form or querystring variables only. That provides a bonus because then the application works with both <strong>GET</strong> and <strong>POST</strong> request.</p>
<h2>7. Minimise ASP Request Object Call.</h2>
<p>This is a common mistake that programmers make. Consider this code which illustrates what NOT to do:</p>
<pre class="brush: vb;">
&lt;%
    If Request.Form(&quot;name&quot;) &lt;&gt; &quot;&quot; Then
    SQL = &quot;INSERT INTO table1 (name) VALUES ('&quot; &amp; Request.Form(&quot;name&quot;) &amp; &quot;')&quot;
    Response.Write &quot;Your name is : &quot; &amp; Request.Form(&quot;name&quot;)
    End If
%&gt;
</pre>
<p>Wherever ASP objects are used, it is better to store session or querystring objects in a variable at the start of the page and subsequently use the variable. What’s happened above is the Request.Form collection keeps getting called over and over again for the &#8220;name&#8221; input, and yet we know that the input&#8217;s value hasn&#8217;t changed. The Engine needs to read the value of from the Querystring collection each time which increases overhead. This translates to cycles wasted and a slowdown in the ASP application. A better way to write that code that would run your ASP page much faster would be like this:</p>
<pre class="brush: vb;">
&lt;%
    Dim name
    name = Request.Form(&quot;name&quot;)

    If name &lt;&gt; &quot;&quot; Then
        SQL = &quot;INSERT INTO table1 (name) VALUES ('&quot; &amp; Request.Form(&quot;name&quot;) &amp; &quot;')&quot;
        Response.Write &quot;Your name is : &quot; &amp; Request.Form(&quot;name&quot;)
    End If
%&gt;
</pre>
<p>Now the collection has only been searched for that input one time. Effectively using this technique throughout your ASP pages will definitely speed up the page.</p>
<h2>8. Open A Database Connection One Time Per Page.</h2>
<p>Database work takes cycles. Consider bad code like this which opens a database more than one time:</p>
<pre class="brush: vb;">
&lt;%
    Dim conn, rs, id

    Set conn = Server.CreateObject(&quot;ADODB.Connection&quot;)
    conn.open &quot;connstring&quot;
    Set rs = Server.CreateObject(&quot;ADODB.recordset&quot;)

    rs.open &quot;SELECT id FROM table1 ORDER BY id DESC&quot;, conn
    id = rs.fields(0).value
    rs.close
    Set rs = nothing

    'Close Database Connection!
    conn.close
    Set conn = nothing

    'Re-Open The Database Connection!
    Set conn = Server.CreateObject(&quot;ADODB.Connection&quot;)
    conn.open &quot;connstring&quot;
    conn.execute &quot;INSERT INTO table1 (id) VALUES(&quot; &amp; id + 1 &amp; &quot;)&quot;

    'Close Database Connection!
    conn.close
    Set conn = nothing
%&gt;
</pre>
<p>What you see above is code which gets a value out of a database and then creates a new row in the same database. This code makes the mistake of closing the database between sql executions. That code will be slower than it could be by rewriting it properly like this:</p>
<pre class="brush: vb;">
&lt;%
    Dim conn, rs, id

    'Open Database Connection
    Set conn = Server.CreateObject(&quot;ADODB.Connection&quot;)
    conn.open &quot;connstring&quot;

    Set rs = Server.CreateObject(&quot;ADODB.recordset&quot;)
    rs.open &quot;SELECT id FROM table1 ORDER BY id DESC&quot;, conn
    id = rs.fields(0).value
    rs.close
    Set rs = nothing

    conn.execute &quot;INSERT INTO table1 (id) VALUES(&quot; &amp; id + 1 &amp; &quot;)&quot;

    'Close Database Connection!
    conn.close
    Set conn = nothing
%&gt;
</pre>
<p>The difference is, the database connection is only opened one time above, saving time. When used comprehensively on every page of a website, these guidelines can make your applications run as fast as possible in the ASP environment.</p>
<h2>9. Reference Columns In A Recordset Ordinally.</h2>
<p>When working with an ADO Recordset object, there are a number of ways to grab the value of a particular column. The most common way is to use the column&#8217;s name. For example, if we had a Recordset object named objRS that had three columns, Name, Age, and Salary, we could display these contents of these three columns for the current row in the Recordset using the following code:</p>
<pre class="brush: vb;">
&lt;%
    Employees Name: &lt;%=objRS(&quot;Name&quot;)%&gt;&lt;br&gt;
    Employees Age: &lt;%=objRS(&quot;Age&quot;)%&gt;&lt;br&gt;
    Employees Salary:&lt;%=objRS(&quot;Salary&quot;)%&gt;&lt;br&gt;
%&gt;
</pre>
<p>These values can also be accessed ordinally. Each column is given an ordinal index starting at zero. Hence, these three columns could also be displayed with the slightly modified code:</p>
<pre class="brush: vb;">
&lt;%
	Employees Name: &lt;%=objRS(0)%&gt;&lt;br&gt;
	Employees Age: &lt;%=objRS(1)%&gt;&lt;br&gt;
	Employees Salary: &lt;%=(objRS(2)%&gt;&lt;br&gt;
%&gt;
</pre>
<p>Now, you may say that using the ordinal notation decreases code readability, and I would agree.</p>
<p>There is a disadvantage of using this method but it can easily be solved. Consider this situation, if more than one person is working on a site, it could get you in trouble. Someone else adding one field to the SQL string NOT at the end will throw off all your code. The solution is to use a constant.</p>
<p>You could use constant to refer to your recordset elements. Although this has a very slight performance penalty in terms of script size and initial interpreter processing, it represents a nice trade-off between code readability and efficiency, example:</p>
<pre class="brush: vb;">
&lt;%
    strSQL = &quot;SELECT Name, Age, Salary from People ORDER BY id&quot;
    Const NAME = 0
    Const AGE = 1
    Const SALARY = 2

    objRS.Open strSQL, conn

    Response.Write (&quot;Employees Name: &quot; &amp; objRS(NAME) &amp; &quot;&lt;br&gt;&quot;)
    Response.Write (&quot;Employees Age: &quot; &amp; objRS(AGE) &amp; &quot;&lt;br&gt;&quot;)
    Response.Write (&quot;Employees Salary: &quot; &amp; objRS(SALARY) &amp; &quot;&lt;br&gt;&quot;)
%&gt;
</pre>
<p>I think that&#8217;s a nice compromise between performance and maintainability/readability&#8230;</p>
<h2>10. Use .HTM As Your Extension</h2>
<p>Use .htm files when possible as they never block and get maximum caching benefits. ASP files are generally blocked. So if the file contains pure HTML, give it an .htm extension. If you can avoid tables, that&#8217;s good news but we can’t always do that, so try to avoid nested complex tables. This will boost the load performance. The solution to this is by using CSS (Cascading Style Sheet) to position your HTML  elements. As I said before, HTML file is executed 3 to 4 times faster than complex ASP script.</p>
<h2>Conclusion</h2>
<p>Now that I&#8217;ve made you sufficiently worried and excited at the same time about your asp applications, I must hasten to tell you that this is only the tip of the iceberg. Best coding practices don&#8217;t come easy. It comes with a passion for self-improvement. Enjoy coding…</p>
<p>Source: <a class="mw" href="http://www.asp101.com">ASP101</a> <a class="mw" href="http://www.4guysfromrolla.com/">4GuysFromRolla</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.moniestudios.com/tutorials/asp_speed_p2/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Sending E-Mail with CDOSYS</title>
		<link>http://www.moniestudios.com/tutorials/asp-mail-cdosys/</link>
		<comments>http://www.moniestudios.com/tutorials/asp-mail-cdosys/#comments</comments>
		<pubDate>Mon, 18 May 2009 04:27:03 +0000</pubDate>
		<dc:creator>Monie</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[asp]]></category>
		<category><![CDATA[cdosys]]></category>
		<category><![CDATA[email]]></category>

		<guid isPermaLink="false">http://www.moniestudios.com/?p=357</guid>
		<description><![CDATA[Learn how you can have your own contact form in your own website with this tutorial on CDOSY.]]></description>
			<content:encoded><![CDATA[<p>Ever wonder how you could send email from your ASP page? Need to create your own contact form but have no clue how to do it? After reading this tutorial, you will find it quiet easy!</p>
<h2>What is CDOSYS?</h2>
<blockquote><p>CDO (Collaboration Data Objects) is a Microsoft technology that is designed to simplify the creation of messaging applications.</p>
<p>CDOSYS is a built-in component in ASP. This component is used to send e-mails with ASP.</p></blockquote>
<p>We all know that whenever you put your email address onto the internet for you to communicate with your visitors, you instantly get hit with tons of spam. This is because a spammer&#8217;s email finder application saw your email address and added it to their nasty hit list.</p>
<p>This is why website owners created a contact form for their visitors to interact with them. With this kind of technology (CDOSYS), you can receive emails from your visitors without letting the general public know your email address, reducing the spammer activity on your site.</p>
<p>This following tutorial will show you how you could send email using ASP built in component to a remote server.</p>
<h2>The Basic HTML</h2>
<p>Before we start worrying about how to send the email, let&#8217;s make a basic HTML form that will gather the following information from the user. Save this file with .htm extension, in this example I&#8217;ll name them as <strong>contact.htm</strong>.</p>
<pre class="brush: xml;">
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Tutorial: Send Email Using CDOSYS&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;

&lt;form name=&quot;feedback&quot; method=&quot;post&quot; action=&quot;cdosys_mail.asp&quot;&gt;
    Your Name : &lt;input type=&quot;text&quot; name=&quot;txtName&quot;&gt;
    Your Email Address: &lt;input type=&quot;text&quot; name=&quot;txtEmail&quot;&gt;
    Cc: &lt;input type=&quot;text&quot; name=&quot;txtCc&quot;&gt;
    Bcc &lt;input type=&quot;text&quot; name=&quot;txtBcc&quot;&gt;
    Subject: &lt;input type=&quot;text&quot; name=&quot;txtSubject&quot;&gt;
    Comment/Suggestion : &lt;textarea name=&quot;txtComment&quot;&gt;&lt;/textarea&gt;
    &lt;input name=&quot;submit&quot; type=&quot;submit&quot;&gt;
&lt;/form&gt;

&lt;/body&gt;
&lt;/html&gt;
</pre>
<h2>The CDOSYS</h2>
<p>Now that we have our HTML Form ready, we need to create the ASP file containing the CDOSYS code that will retrieve this data and shoot off an email. All the properties that are set in the following code are self-explanatory and write only. Please take note that a Message is an object, it must be Set equal to nothing after we have finished with it to release the memory allocated to it.</p>
<p>Save this file with .asp extension and in the same directory with your previous html form. In our previous html form, we have a form action pointing to <strong>cdosys_mail.asp</strong> which is the name that we will give to this page.</p>
<pre class="brush: vb;">
&lt;%
Dim txtName, txtEmail, txtCc, txtBcc, txtSubject, txtComment, htmlBody
    txtName = Request.Form(&quot;txtName&quot;)
    txtEmail = Request.Form(&quot;txtEmail&quot;)
    txtCc = Request.Form(&quot;txtCc&quot;)
    txtBcc = Request.Form(&quot;txtBcc&quot;)
    txtSubject = Request.Form(&quot;txtSubject&quot;)
    txtComment = Request.Form(&quot;txtComment&quot;)

    htmlBody = &quot;&lt;b&gt;Tutorial: Send Email Using CDOSYS&lt;/b&gt;&lt;br&gt;&quot;
    htmlBody = htmlBody &amp; txtComment

Dim objCDOSYSCon
Set objCDOSYSMail = Server.CreateObject(&quot;CDO.Message&quot;)
Set objCDOSYSCon = Server.CreateObject (&quot;CDO.Configuration&quot;)
	objCDOSYSCon.Fields(&quot;http://schemas.microsoft.com/cdo/configuration/smtpserver&quot;) = &quot;YourMailServerAddress&quot;
	objCDOSYSCon.Fields(&quot;http://schemas.microsoft.com/cdo/configuration/smtpserverport&quot;)  = 25 'Your mail SMTP Port Number
	objCDOSYSCon.Fields(&quot;http://schemas.microsoft.com/cdo/configuration/sendusing&quot;) = 2
	objCDOSYSCon.Fields(&quot;http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout&quot;) = 60 'Timeout Setting
	objCDOSYSCon.Fields.Update

Set objCDOSYSMail.Configuration = objCDOSYSCon
    objCDOSYSMail.From = txtEmail
    objCDOSYSMail.To = webmaster@mywebsite.com 'Set your email address here!
    objCDOSYSMail.Cc = txtCc
    objCDOSYSMail.Bcc = txtBcc
    objCDOSYSMail.Subject = txtSubject
    objCDOSYSMail.HTMLBody = htmlBody
    objCDOSYSMail.Send 'Send the email out

'Clear connection and redirect user
Set objCDOSYSMail = Nothing
Set objCDOSYSCon = Nothing
Set adoCon = Nothing

Response.Redirect &quot;email_successfully_sent_message.asp&quot;
%&gt;
</pre>
<p>Please note that this is a very basic ASP Email Form and is only for tutorial purposes. If you were to use this code on your web site, you would want to do some form validation to make sure the email addresses are valid, compulsory field are filled in, allow for attachments, etc.</p>
<p>That&#8217;s just it. Your site are now ready to received email from your visitors!</p>
<p><a class="mw" href="http://www.moniestudios.com/wp-content/uploads/attachment/cdosys.zip">Download The Full Code</a></p>
<p>Source: <a class="mw" href="http://www.w3schools.com">W3Schools</a> <a class="mw" href="http://www.tizag.com">Tizag</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.moniestudios.com/tutorials/asp-mail-cdosys/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ASP Active Visitors Counter</title>
		<link>http://www.moniestudios.com/tutorials/asp_counter/</link>
		<comments>http://www.moniestudios.com/tutorials/asp_counter/#comments</comments>
		<pubDate>Tue, 28 Apr 2009 23:30:53 +0000</pubDate>
		<dc:creator>Monie</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[asp]]></category>
		<category><![CDATA[counter]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[visitor]]></category>

		<guid isPermaLink="false">http://www.moniestudios.com/?p=53</guid>
		<description><![CDATA[Learn how to do a simple visitor access counter with ASP.]]></description>
			<content:encoded><![CDATA[<p>How many people are accessing your web site at any particular time? With this script we will be able to know and show in our pages the number of active visitors in a given moment. The script has two parts: a file name global.asa, and a small code you must insert in your pages to show the number of active users.</p>
<h2>The Global.ASA file</h2>
<p style="clear: both;">In this quick little tutorial, we are going to take a look at building a routine that checks to see how many people are accessing your web site at any particular time. In order to achieve this, we are going to use something called the global.asa file.</p>
<h2>What is the global.asa file?</h2>
<p>As you all probably know, &#8220;ASP&#8221; stands for Active Server Pages. We use ASP pages to execute script on the server enabling us to interact with databases and create dynamic content for our web site. &#8220;ASA&#8221; on the other hand stands for &#8220;Active Server Application&#8221;.</p>
<p>The &#8220;global.asa&#8221; file is created in order to contain scripts that can be accessed &#8220;globally&#8221; by the entire web site.<br />
The Global file is a file in which (amongst other things) you can specify event scripts and declare objects that have session or application wide scope. It is not a content file and nothing in it is displayed directly to the users; instead it stores event information and objects used globally by the application.</p>
<ul>
<li>The file must be named global.asa</li>
<li>It must be stored in the root directory your application/website (/global.asa).</li>
<li>Your application can only have one global.asa file.</li>
</ul>
<h2>What are Applications and Sessions?</h2>
<p><strong>Application:</strong><br />
As mentioned above, an application (in ASP terms) refers to your asp web site. An <span style="text-decoration: underline;">Application</span> starts when the web server is switched on and ends when the web server stops.</p>
<p><strong>Session:</strong><br />
A <span style="text-decoration: underline;">Session</span> starts from the time a visitor starts looking at your site and ends (in theory) when the visitor leaves your site. In practice though, a session has a 20 minute default &#8220;timeout”. In order to keep track of the session a cookie is created for the visitor. This cookie is deleted when the user closes his browser. All session data is stored on the server.</p>
<h2>Global.asa file content.</h2>
<p>A typical gobal.asa file would contain the following events:</p>
<ul>
<li><strong>Application_OnStart</strong> &#8211; Is executed when the server is switched on and before the first session is started.</li>
<li><strong>Application_OnEnd</strong> &#8211; Is executed when the application is finished (i.e. the server is switched off).</li>
<li><strong>Session_OnStart</strong> &#8211; Is executed when the server creates a new session (i.e. when a new client accesses your web site).</li>
<li><strong>Session_OnEnd</strong> &#8211; Is executed when a session is abandoned or after certain period of inactivity between the visitor and the server (by default after a lapse of 20 minutes from the last request from a visitor the server will consider he is not going to come back and will delete any information related to that session).</li>
</ul>
<h2>Script for the global.asa file:</h2>
<pre class="brush: vb;">
&lt;Script Language=&quot;VBScript&quot; RUNAT=&quot;Server&quot;&gt;
Sub Application_OnStart
    Application( &quot;WhosOnline&quot; ) = 0
End Sub
Sub Application_OnEnd
End Sub
Sub Session_OnStart
    Application.Lock
    Application( &quot;WhosOnline&quot; ) = Application( &quot;WhosOnline&quot; )+1
    Application.UnLock
End Sub
Sub Session_OnEnd
    Application.Lock
    Application( &quot;WhosOnline&quot; ) = Application( &quot;WhosOnline&quot; )-1
    Application.UnLock
End Sub
&lt;/Script&gt;
</pre>
<h2>What the script does…</h2>
<table class="MsoNormalTable" style="border: 1pt solid windowtext; width: 450.75pt;" border="1" cellpadding="0" width="601">
<tbody>
<tr>
<td style="border: 1pt solid windowtext; padding: 1.5pt; width: 16.75pt;" width="22" valign="top">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;; color: #000066;">1</span></p>
</td>
<td style="border: 1pt solid windowtext; padding: 1.5pt; width: 190pt;" width="253" valign="top">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 8pt; font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;;">&lt;Script Language=&#8221;VBScript&#8221;   RUNAT=&#8221;Server&#8221;&gt; </span><span style="font-size: 8pt; font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;;"> </span></p>
</td>
<td style="border: 1pt solid windowtext; padding: 1.5pt; width: 238pt;" width="317" valign="top">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;; color: #76923c;">Opens the script. Note that you must never use the ASP &lt;%   %&gt; delimiters in a global.asa file</span></p>
</td>
<tr>
<td style="border: 1pt solid windowtext; padding: 1.5pt;" valign="top">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;; color: #000066;">2</span></p>
</td>
<td style="border: 1pt solid windowtext; padding: 1.5pt; width: 190pt;" width="253" valign="top">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 8pt; font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;;">Sub Application_OnStart</span></p>
</td>
<td style="border: 1pt solid windowtext; padding: 1.5pt; width: 238pt;" width="317" valign="top">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;; color: #76923c;">Sets up the Application subroutine when the server starts</span></p>
</td>
</tr>
<tr>
<td style="border: 1pt solid windowtext; padding: 1.5pt;" valign="top">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;; color: #000066;">3</span></p>
</td>
<td style="border: 1pt solid windowtext; padding: 1.5pt; width: 190pt;" width="253" valign="top">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 8pt; font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;;">Application( &#8220;WhosOnline&#8221; ) = 0</span></p>
</td>
<td style="border: 1pt solid windowtext; padding: 1.5pt; width: 238pt;" width="317" valign="top">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;; color: #76923c;">Names the Application &#8220;WhosOnline&#8221; and sets initial   value to zero.</span></p>
</td>
</tr>
<tr>
<td style="border: 1pt solid windowtext; padding: 1.5pt;" valign="top">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;; color: #000066;">4</span></p>
</td>
<td style="border: 1pt solid windowtext; padding: 1.5pt; width: 190pt;" width="253" valign="top">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 8pt; font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;;">End Sub</span></p>
</td>
<td style="border: 1pt solid windowtext; padding: 1.5pt; width: 238pt;" width="317" valign="top">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;; color: #76923c;">Closes the Application subroutine set up procedure.</span></p>
</td>
</tr>
<tr>
<td style="border: 1pt solid windowtext; padding: 1.5pt;" valign="top">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;; color: #000066;">5</span></p>
</td>
<td style="border: 1pt solid windowtext; padding: 1.5pt; width: 190pt;" width="253" valign="top">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 8pt; font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;;">Sub Application_OnEnd</span></p>
</td>
<td style="border: 1pt solid windowtext; padding: 1.5pt; width: 238pt;" rowspan="2" width="317" valign="top">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;; color: #76923c;">Closes the Application subroutine in the event of the server   closing down</span></p>
</td>
</tr>
<tr>
<td style="border: 1pt solid windowtext; padding: 1.5pt;" valign="top">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;; color: #000066;">6</span></p>
</td>
<td style="border: 1pt solid windowtext; padding: 1.5pt; width: 190pt;" width="253" valign="top">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 8pt; font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;;">End Sub</span></p>
</td>
</tr>
<tr>
<td style="border: 1pt solid windowtext; padding: 1.5pt;" valign="top">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;; color: #000066;">7</span></p>
</td>
<td style="border: 1pt solid windowtext; padding: 1.5pt; width: 190pt;" width="253" valign="top">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 8pt; font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;;">Sub Session_OnStart</span></p>
</td>
<td style="border: 1pt solid windowtext; padding: 1.5pt; width: 238pt;" width="317" valign="top">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;; color: #76923c;">Sets up a subroutine for when a session opens.</span></p>
</td>
</tr>
<tr>
<td style="border: 1pt solid windowtext; padding: 1.5pt;" valign="top">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;; color: #000066;">8</span></p>
</td>
<td style="border: 1pt solid windowtext; padding: 1.5pt; width: 190pt;" width="253" valign="top">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 8pt; font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;;">Application.Lock</span></p>
</td>
<td style="border: 1pt solid windowtext; padding: 1.5pt; width: 238pt;" width="317" valign="top">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;; color: #76923c;">Locks access so that only 1 person at a time can write to a   session. </span></p>
</td>
</tr>
<tr>
<td style="border: 1pt solid windowtext; padding: 1.5pt;" valign="top">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;; color: #000066;">9</span></p>
</td>
<td style="border: 1pt solid windowtext; padding: 1.5pt; width: 190pt;" width="253" valign="top">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 8pt; font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;;">Application( &#8220;WhosOnline&#8221; ) =   Application( &#8220;WhosOnline&#8221; )+1</span></p>
</td>
<td style="border: 1pt solid windowtext; padding: 1.5pt; width: 238pt;" width="317" valign="top">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;; color: #76923c;">Increments the count by 1 every time a new session is created</span></p>
</td>
</tr>
<tr>
<td style="border: 1pt solid windowtext; padding: 1.5pt;" valign="top">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;; color: #000066;">10</span></p>
</td>
<td style="border: 1pt solid windowtext; padding: 1.5pt; width: 190pt;" width="253" valign="top">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 8pt; font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;;">Application.UnLock</span></p>
</td>
<td style="border: 1pt solid windowtext; padding: 1.5pt; width: 238pt;" width="317" valign="top">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;; color: #76923c;">Unlocks the application so that the next visitor can create a   session. </span></p>
</td>
</tr>
<tr>
<td style="border: 1pt solid windowtext; padding: 1.5pt;" valign="top">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;; color: #000066;">11</span></p>
</td>
<td style="border: 1pt solid windowtext; padding: 1.5pt; width: 190pt;" width="253" valign="top">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 8pt; font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;;">End Sub</span></p>
</td>
<td style="border: 1pt solid windowtext; padding: 1.5pt; width: 238pt;" width="317" valign="top">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;; color: #76923c;">Ends that section of the subroutine.</span></p>
</td>
</tr>
<tr>
<td style="border: 1pt solid windowtext; padding: 1.5pt;" valign="top">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;; color: #000066;">12</span></p>
</td>
<td style="border: 1pt solid windowtext; padding: 1.5pt; width: 190pt;" width="253" valign="top">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 8pt; font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;;">Sub Session_OnEnd</span></p>
</td>
<td style="border: 1pt solid windowtext; padding: 1.5pt; width: 238pt;" width="317" valign="top">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;; color: #76923c;">Sets up a subroutine for when a session closes</span></p>
</td>
</tr>
<tr>
<td style="border: 1pt solid windowtext; padding: 1.5pt;" valign="top">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;; color: #000066;">13</span></p>
</td>
<td style="border: 1pt solid windowtext; padding: 1.5pt; width: 190pt;" width="253" valign="top">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 8pt; font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;;">Application.Lock</span></p>
</td>
<td style="border: 1pt solid windowtext; padding: 1.5pt; width: 238pt;" width="317" valign="top">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;; color: #76923c;">Locks access so that only 1 person at a time can write to the   session. </span></p>
</td>
</tr>
<tr>
<td style="border: 1pt solid windowtext; padding: 1.5pt;" valign="top">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;; color: #000066;">14</span></p>
</td>
<td style="border: 1pt solid windowtext; padding: 1.5pt; width: 190pt;" width="253" valign="top">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 8pt; font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;;">Application( &#8220;WhosOnline&#8221; ) =   Application( &#8220;WhosOnline&#8221; )-1</span></p>
</td>
<td style="border: 1pt solid windowtext; padding: 1.5pt; width: 238pt;" width="317" valign="top">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;; color: #76923c;">decreases the count by 1 every time a session is closed.</span></p>
</td>
</tr>
<tr style="height: 17.25pt;">
<td style="border: 1pt solid windowtext; padding: 1.5pt; height: 17.25pt;" valign="top">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;; color: #000066;">15</span></p>
</td>
<td style="border: 1pt solid windowtext; padding: 1.5pt; width: 190pt; height: 17.25pt;" width="253" valign="top">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 8pt; font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;;">Application.UnLock</span></p>
</td>
<td style="border: 1pt solid windowtext; padding: 1.5pt; width: 238pt; height: 17.25pt;" width="317" valign="top">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;; color: #76923c;">Unlocks the application </span></p>
</td>
</tr>
<tr>
<td style="border: 1pt solid windowtext; padding: 1.5pt;" valign="top">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;; color: #000066;">16</span></p>
</td>
<td style="border: 1pt solid windowtext; padding: 1.5pt; width: 190pt;" width="253" valign="top">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 8pt; font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;;">End Sub</span></p>
</td>
<td style="border: 1pt solid windowtext; padding: 1.5pt; width: 238pt;" width="317" valign="top">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;; color: #76923c;">Ends this section of the subroutine.</span></p>
</td>
</tr>
<tr>
<td style="border: 1pt solid windowtext; padding: 1.5pt;" valign="top">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;; color: #000066;">17</span></p>
</td>
<td style="border: 1pt solid windowtext; padding: 1.5pt; width: 190pt;" width="253" valign="top">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 8pt; font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;;">&lt;/Script&gt;</span></p>
</td>
<td style="border: 1pt solid windowtext; padding: 1.5pt; width: 238pt;" width="317" valign="top">
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;; color: #76923c;">Closes the script.</span></p>
</td>
</tr>
</tbody>
</table>
<h2>Script for displaying the results on a web page&#8230;</h2>
<p>Displaying the results on a page is simply a case of adding this 1 line of code to the area on your page where you want the number to be displayed.</p>
<pre class="brush: vb;">
There are currently &lt;%=Application(&quot;WhosOnline&quot;)%&gt; active visitors!
</pre>
<p>See how simple it is in retrieving the value of your active visitors counter stored in the application object. Now, every time a visitor comes to your .asp application / homepage you can see the actual number of visitors in your page. Also, you can extend the code above to use images of numbers as your counter display.</p>
<p>And that&#8217;s about it really. Just a few things to remember!</p>
<ul>
<li>You can only have one global.asp file for your web site but that file can contain more than one sub routine.</li>
<li>The global.asp file must live in the root folder for your site.</li>
<li>If you already have a global.asp for your site simply add the code we have been discussing to the file.</li>
<li>If you are embarrassed by the lack of people on your site at any particular time you can cheat by changing the &#8220;0&#8243; in line 3 to a higher starting number.</li>
</ul>
<p>Have fun with ASP…!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.moniestudios.com/tutorials/asp_counter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ASP Cache Control</title>
		<link>http://www.moniestudios.com/tutorials/asp_cache/</link>
		<comments>http://www.moniestudios.com/tutorials/asp_cache/#comments</comments>
		<pubDate>Tue, 28 Apr 2009 05:09:29 +0000</pubDate>
		<dc:creator>Monie</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[asp]]></category>
		<category><![CDATA[cache]]></category>
		<category><![CDATA[control]]></category>

		<guid isPermaLink="false">http://www.moniestudios.com/?p=10</guid>
		<description><![CDATA[This simple tutorial will show you how you be able to control you page cache with Active Server Page (ASP).]]></description>
			<content:encoded><![CDATA[<p>Don&#8217;t allow your page to be cached. Why? You might want to prevent users from seeing old content. Another big concern is when someone is filling out forms. You really don&#8217;t want the pages cached because if they are, credit card numbers and addresses and all kinds of stuff can be gathered from the cached page. Here is how ASP do it!</p>
<h2>Cache No More!</h2>
<pre class="brush: vb;">
&lt;% @LANGUAGE=&quot;VBSCRIPT&quot; %&gt;
&lt;%
Option Explicit
Response.Buffer = True

'Make sure this page is not cached by the browser!
Response.Expires = -1
Response.ExpiresAbsolute = Now() - 1
Response.AddHeader &quot;pragma&quot;,&quot;no-cache&quot;
Response.AddHeader &quot;cache-control&quot;,&quot;private&quot;
Response.CacheControl = &quot;No-Store&quot;

'Description:
#07 That sets an immediate expiration on the file. Thus it dies the moment is it born.
#08 Says &quot;Expire this page 24 hours ago&quot;, allowing for time differences, rather than specify a static date.
#09 Tell the browser not to cache the page.
#10 Better safe than sorry!
#11 Tell the browser not to store anything from this page.
%&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.moniestudios.com/tutorials/asp_cache/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
