- 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)