L
Lewis Edward Moten III
I have a file that users can download through a web page protected by
forms authentication:
Download.aspx?ID=45
and within that file ...
FileInfo fileToDownload = new FileInfo(fileName);
Response.AppendHeader("Content-Length",
fileToDownload.Length.ToString());
Response.ContentType = "application/octet-stream";
string disposition = "inline";
if(Path.GetExtension(fileName).ToLower() == ".xls")
disposition = "attachment";
Response.AppendHeader("Content-Disposition",
disposition + "; " +
"filename=" + fileToDownload.Name + "; " +
"size=" + fileToDownload.Length.ToString() + "; " +
"creation-date=" + fileToDownload.CreationTime.ToString("R") + "; " +
"modification-date=" + fileToDownload.LastWriteTime.ToString("R") +
"; " +
"read-date=" + fileToDownload.LastAccessTime.ToString("R"));
Response.Flush();
Response.WriteFile(fileToDownload.FullName);
===============
Ok, here is the problem. When user logs in directly to my file, they
are prompted to login. After doing so, they are redirected to the
original page that they requested. However, when the excel document
opens, it appears that the html code from the login page appears in
the excel document. I got past this by specifying that the
disposition must be an attachment if the client is requesting an excel
document. However, this problem still keeps creeping up at times.
Also, I need to show the excel document inline - but that pretty much
guarentees that the document will show up as a login form. I've tried
messing with caching headers as well as my internet options cache
settings within the browser. I keep getting so many different results
that it is driving me crazy. I need stability here. My browser
usually prompts me if I want to Open the document, or save it to my
file system. Saving is fine. Perfect. If i save and open, the
correct information is in the excel document. If I open the document,
the login form appears. I've even tried setting up the content type
specific to excel documents and still have this problem.
Does anyone know of a work around so that the login page is not
displayed when requesting a dynamically generated excel file through
forms authentication after the user has been authenticated?
forms authentication:
Download.aspx?ID=45
and within that file ...
FileInfo fileToDownload = new FileInfo(fileName);
Response.AppendHeader("Content-Length",
fileToDownload.Length.ToString());
Response.ContentType = "application/octet-stream";
string disposition = "inline";
if(Path.GetExtension(fileName).ToLower() == ".xls")
disposition = "attachment";
Response.AppendHeader("Content-Disposition",
disposition + "; " +
"filename=" + fileToDownload.Name + "; " +
"size=" + fileToDownload.Length.ToString() + "; " +
"creation-date=" + fileToDownload.CreationTime.ToString("R") + "; " +
"modification-date=" + fileToDownload.LastWriteTime.ToString("R") +
"; " +
"read-date=" + fileToDownload.LastAccessTime.ToString("R"));
Response.Flush();
Response.WriteFile(fileToDownload.FullName);
===============
Ok, here is the problem. When user logs in directly to my file, they
are prompted to login. After doing so, they are redirected to the
original page that they requested. However, when the excel document
opens, it appears that the html code from the login page appears in
the excel document. I got past this by specifying that the
disposition must be an attachment if the client is requesting an excel
document. However, this problem still keeps creeping up at times.
Also, I need to show the excel document inline - but that pretty much
guarentees that the document will show up as a login form. I've tried
messing with caching headers as well as my internet options cache
settings within the browser. I keep getting so many different results
that it is driving me crazy. I need stability here. My browser
usually prompts me if I want to Open the document, or save it to my
file system. Saving is fine. Perfect. If i save and open, the
correct information is in the excel document. If I open the document,
the login form appears. I've even tried setting up the content type
specific to excel documents and still have this problem.
Does anyone know of a work around so that the login page is not
displayed when requesting a dynamically generated excel file through
forms authentication after the user has been authenticated?