473,326 Members | 2,588 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

beginners help

i have the following code in counter.cs but i get errors regarding request,
application, session. I know im missing something but dont know what it is.

thnx

using System.IO;
namespace luke_smith
{
/// <summary>
/// Summary description for counter.
/// </summary>
public class counter
{
public counter()
{
int counterid = request("id");
int iValue = cint(Application("Counter_" + counterid));
// Get the counter ID (unique to each counter in the site)
if (Session("CounterTemp_" + counterid) == Nothing)
{
// If the text file exists load the saved value
// Always loading it from the file rather than just using the application
variable allows for manual modification of counter values while the
application is running (by editing the text file). To stop it from being
able to be modified just uncomment the following 'if..then' and the 'end
if'. This will give a slight performance boost to the counter incrementing
as it will stop a file operation. Yes, I'm an optimization freak! :)
//if value = 0 then
if (File.Exists(server.mappath(counterid + ".txt")))
{
StreamReader sr = File.OpenText(server.mappath(counterid + ".txt"));
ivalue = cint(sr.ReadLine().ToString());
sr.Close;
}
// Increment counter
ivalue =++ 1;
// Save counter to an application var (the locks are there to make sure
noone else changes it at the same time)
Application.Lock();
Application("Counter_" + counterid) = ivalue.ToString();
Application.UnLock();
// Save counter to a text file
FileStream fs = new FileStream(server.mappath(counterid + ".txt"),
FileMode.Create, FileAccess.Write);
StreamWriter sw = new StreamWriter(fs);
sw.WriteLine(Convert.ToString(ivalue));
sw.Close;
fs.Close;
// Set a session variable so this counter doesn't fire again in the current
session
Session.Add(("CounterTemp_" + counterid), "True");
}
}
}
}
Nov 15 '05 #1
1 1210
Hi Luke,

You obviously miss the following line:

using System.Web;

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"Luke Smith" <lu**********@btinternet.com> wrote in message
news:e3**************@TK2MSFTNGP09.phx.gbl...
i have the following code in counter.cs but i get errors regarding request, application, session. I know im missing something but dont know what it is.
thnx

using System.IO;
namespace luke_smith
{
/// <summary>
/// Summary description for counter.
/// </summary>
public class counter
{
public counter()
{
int counterid = request("id");
int iValue = cint(Application("Counter_" + counterid));
// Get the counter ID (unique to each counter in the site)
if (Session("CounterTemp_" + counterid) == Nothing)
{
// If the text file exists load the saved value
// Always loading it from the file rather than just using the application
variable allows for manual modification of counter values while the
application is running (by editing the text file). To stop it from being
able to be modified just uncomment the following 'if..then' and the 'end
if'. This will give a slight performance boost to the counter incrementing
as it will stop a file operation. Yes, I'm an optimization freak! :)
//if value = 0 then
if (File.Exists(server.mappath(counterid + ".txt")))
{
StreamReader sr = File.OpenText(server.mappath(counterid + ".txt"));
ivalue = cint(sr.ReadLine().ToString());
sr.Close;
}
// Increment counter
ivalue =++ 1;
// Save counter to an application var (the locks are there to make sure
noone else changes it at the same time)
Application.Lock();
Application("Counter_" + counterid) = ivalue.ToString();
Application.UnLock();
// Save counter to a text file
FileStream fs = new FileStream(server.mappath(counterid + ".txt"),
FileMode.Create, FileAccess.Write);
StreamWriter sw = new StreamWriter(fs);
sw.WriteLine(Convert.ToString(ivalue));
sw.Close;
fs.Close;
// Set a session variable so this counter doesn't fire again in the current session
Session.Add(("CounterTemp_" + counterid), "True");
}
}
}
}


Nov 15 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: P.Hill | last post by:
I was just trying to install Apache and php on an XP box for test of a PHP website I built last year. It was my first and only, so I am now rusty about the little I did learn last year. I get...
7
by: Will | last post by:
Pardon two post in a row to the newsgroup but I want to try and expedite this, if you guys don't mind helping out... I running Windows XP Pro and wanted to download Python and any additional...
7
by: tada991 | last post by:
Hello Everyone, I just purchased Visual Studio .Net Architect 2003 and want to know what's a good book for begginers to start with. I know nothing about programming whatsoever, but I do have a...
6
by: Tony Williams | last post by:
Can someone recommend a good easy to read beginners guide to VB for Access 2000? I did get a list from someone but lost it in a disc crash Thanks Tony Williams
55
by: Cindy | last post by:
Hello!! I'm new at access and there's is an article by Arvin Meyer for beginners that is references in Google Groups but I can't seem to find the original post with the article's URL. Does anyone...
4
by: Eggnog | last post by:
Hi, Is there a newsgroups for beginners questions? Cheers, Nawg
2
by: =?Utf-8?B?UmFrZXNo?= | last post by:
Hi, I have worked in Windows development for some time and want to learn ASP.Net - Web Application. Can some one redirect me to some site where I can find some good start up for beginners course...
4
by: aman firoz | last post by:
do you people got anything for c beginners..... help me out guys
0
by: Dual_b00t | last post by:
hi i created a site called PHP Together its for beginners also for gurus to help out the beginners if you are learning PHP and feel alone then drop by . ciao Mark
19
by: yltkhuu | last post by:
1. How does having a widely adopted C++ standard help game programmers? 2. What are the advantages ans disadvantages of employing the "using" directive? 3. Why might you define a new name for an...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.