Dotnet session 的问题,不知道怎么解决 ------Ipower.net.cn

王朝c#·作者佚名  2006-01-09
宽屏版  字体: |||超大  

在dotnet里 当创建一个文件并写入数据的时候,session会丢失,奇怪

无论是使用FileStream 还是StreamWriter 都存在这个问题.

FileStream flog=null;

try

{

flog=File.Create(ConfigurationSettings.AppSettings["LogFile"]+System.DateTime.Now.Month+"-"+System.DateTime.Now.Day,4096);

//flog.Seek(0,SeekOrigin.End);

byte[] bs=new byte[3];

bs[0]=12;

bs[1]=12;

bs[2]=50;

flog.Write(bs,0,3);

flog.Close();

Response.Write("OK\r\n");

}catch(Exception ex)

{

Response.Write(ex.Message);

}

*/

StreamWriter slog=null;

try

{

slog=File.AppendText(ConfigurationSettings.AppSettings["LogFile"]+System.DateTime.Now.Month+"-"+System.DateTime.Now.Day);

slog.WriteLine("this is new test");

slog.Close();

Response.Write("OK\r\n");

}catch(Exception ex)

{

Response.Write(ex.Message);

}

当用户在另外一个页面里面设置了Session["User"]="Test File"

Response.Write("User is null:"+(Session["User"]==null)+"\r\n");

结果是 Session["User"] 不存在.

大家可以测试一下看看.

www.ipower.net.cn 专业域名,虚拟主机,企业邮箱供应商, 网络时代新动力

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
© 2005- 王朝网络 版权所有