StreamWriter.Write or WriteLine causes Session_End

  • Thread starter Thread starter xuxu
  • Start date Start date
X

xuxu

If you use StreamWrite Write or WriteLine it causes Session to End!
e.g.
FileStream fs = File.Open(fileName,FileMode.Append,FileAccess.Write);
StreamWriter sw = new StreamWriter(fs);
sw.Write("test");
sw.Close();
fs.Close();

Now all session information is lost!!
Is there a work around for this ?
 
xuxu said:
If you use StreamWrite Write or WriteLine it causes Session to End!
e.g.
FileStream fs = File.Open(fileName,FileMode.Append,FileAccess.Write);
StreamWriter sw = new StreamWriter(fs);
sw.Write("test");
sw.Close();
fs.Close();

Now all session information is lost!!
Is there a work around for this ?

I bet your code is throwing an exception which you're not catching. Put a
try-catch block around it and find out.
 
John Saunders said:
I bet your code is throwing an exception which you're not catching. Put a
try-catch block around it and find out.

No the code is NOT throwing an exception all it does is write to a
file. Even
if it did throw an exception and it was unhandled it should NOT cause
a Session End event thus COMPLETELY wiping out all the user's info
saved in the Session. Other people are also having this problem but
they've posted in Italian and Dutch so I can't communicate with them,
here are there posts.

Subject: StreamWriter BUG ??
URL: http://groups.google.com/groups?q=S...7-2bfb-4ada-818d-c7831511058e@UGI27996&rnum=2

Subject: [ASP.NET] Session End?
URL: http://groups.google.com/groups?q=S...8&[email protected]&rnum=3
 
Did you attempt to place a try block around the code? If so, what was the
result?

--
John Saunders
johnwsaundersiii at hotmail


xuxu said:
"John Saunders" <[email protected]> wrote in message
I bet your code is throwing an exception which you're not catching. Put a
try-catch block around it and find out.

No the code is NOT throwing an exception all it does is write to a
file. Even
if it did throw an exception and it was unhandled it should NOT cause
a Session End event thus COMPLETELY wiping out all the user's info
saved in the Session. Other people are also having this problem but
they've posted in Italian and Dutch so I can't communicate with them,
here are there posts.

Subject: StreamWriter BUG ??
URL: http://groups.google.com/groups?q=S...7-2bfb-4ada-818d-c7831511058e@UGI27996&rnum=2

Subject: [ASP.NET] Session End?
URL:
http://groups.google.com/groups?q=S...8&[email protected]&rnum=3
 
The issue was the security setting of the directory being written to.
Once the security was reset the problem went away.
But there was NO exception thrown!!
Thank you for you're help.
 
Back
Top