Thanks Steve.
I intended to implement a counter for my webpage. I store my counter value
in a text file located in the ApplicationPath. I will read the counter from
the file on application start up and increment the value on every new
session created. Counter will be written on to the file at the end of
application.
If there is no Request yet during the application start up, is there any way
for me to know the ApplicationPath. At the moment, I am using hard coded
path.
OR let me know if there is other way to implement a counter.
Thanks,
Kian
====================================
INSIDE protected void Application_Start(...)
====================================
StreamReader sr = File.OpenText("d:\\kk\\omac\\omacCounter.txt");
Application["Counter"] =
System.Convert.ToInt16(sr.ReadToEnd().ToString());
====================================
"Steve C. Orr, MCSD" <St***@Orr.net> wrote in message
news:e2**************@TK2MSFTNGP09.phx.gbl...
There is no Request yet when your application is starting up.
The Request object is not yet in scope.
--
I hope this helps,
Steve C. Orr, MCSD
http://Steve.Orr.net
"Kian Goh" <ki************@hotmail.com> wrote in message
news:eP****************@tk2msftngp13.phx.gbl... Hi,
Can somebody tell me why can't I use
string strPath = Server.MapPath(Request.ApplicationPath);
in
protected void Application_Start(...)
It compiles ok but an unhandled exception occurred during the execution.
Exception Details: System.NullReferenceException: Object reference not
set to an instance of an object.
I have no problem using the above code in private void Page_Load(...)
Thanks,
Kian