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

Ramendra

I suppose you have solved your problem by changing some settings. I hav
also came across the same problem and want to solve it.

Please mention the exact steps you have taken to solve this problem.

I also tried playing with the security settings on the respectiv
directory but it didn;t help me at all. I gave full control to th
aspnet user over that directory and it didn;t work.

please advice.

thanks, Ramendr
 

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

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top