在创建新会话后检查IsNewSession()时会话重置

时间:2013-03-01 06:16:05

标签: asp.net iis-7

  • IIS7.5
  • Windows Server 2008
  • Asp.net4.0

但它的工作正常 IIS5.1

fileContent = @"<table><tr><td>Name</td><td>Age</td><td></td></tr></table>";


       // byte[] content = fileContent.ToByteArray();

        HttpContext currentRequest = System.Web.HttpContext.Current;

        //fileContent = currentRequest.Server.HtmlEncode(fileContent);  

        currentRequest.Response.Clear();
        currentRequest.Response.ClearContent();
        currentRequest.Response.ClearHeaders();
        //currentRequest.Response.AddHeader("Accept-Ranges", "bytes");
        currentRequest.Response.Buffer = true;


        //fileName = currentRequest.Server.UrlEncode( fileName); 



        if (toDownload)
        {
            currentRequest.Response.AddHeader("Content-Disposition", string.Format("attachment; filename=\"{0}\"", fileName));
        }
        else
        {
            currentRequest.Response.AddHeader("Content-Disposition", string.Format("filename=\"{0}\"", fileName));
        }
        currentRequest.Response.AddHeader("Content-Length", fileContent.Length.ToString());
        //currentRequest.Response.ContentType = GetContentType(StreamFileType.MSOffice2003ExcelDocument);
        currentRequest.Response.ContentType = "application/vnd.xls";
        currentRequest.Response.Write(fileContent);
        currentRequest.Response.Flush();
        currentRequest.Response.Close();

        HttpContext.Current.ApplicationInstance.CompleteRequest();

只要文件在新页面中打开,就会创建新的SessioniD。

如果我检查会话它会重置

if (this.Session.IsNewSession)

0 个答案:

没有答案