StreamWriter.Write or WriteLine causes Session_End

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 ?
 
J

John Saunders

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.
 
X

xuxu

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
 
J

John Saunders

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
 
X

xuxu

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top