if(!System.IO.File.Exists(strFile))
{
Response.Write("<script language='javascript'>alert('对不起,文件不存在!');</script>");
return;
}
FileInfo fi=new FileInfo(strFile);
string ct = Response.ContentType; Response.Clear();
strFile=HttpUtility.UrlEncode(strFile,System.Text.Encoding.UTF8);
Response.AppendHeader("Content-Disposition","attachment; filename="+Path.GetFileName(strFile));
Response.AppendHeader("Content-Length", fi.Length.ToString());
Response.ContentType = "application/octet-stream";
FileStream fs=fi.OpenRead();
byte[] tmpbyte=new byte[fi.Length];
fs.Read(tmpbyte,0,tmpbyte.Length);
fs.Close();
Response.BinaryWrite(tmpbyte);
//Response.Flush();
//Response.ContentType = ct;
Response.End();
通过测试发现Response.AppendHeader("Content-Disposition","attachment; filename="+Path.GetFileName(strFile)); 这段代码加上,在其他机器上访问就返回到登录页面了,但这段代码在本机上用没有问题!这是什么原因啊?
{
Response.Write("<script language='javascript'>alert('对不起,文件不存在!');</script>");
return;
}
FileInfo fi=new FileInfo(strFile);
string ct = Response.ContentType; Response.Clear();
strFile=HttpUtility.UrlEncode(strFile,System.Text.Encoding.UTF8);
Response.AppendHeader("Content-Disposition","attachment; filename="+Path.GetFileName(strFile));
Response.AppendHeader("Content-Length", fi.Length.ToString());
Response.ContentType = "application/octet-stream";
FileStream fs=fi.OpenRead();
byte[] tmpbyte=new byte[fi.Length];
fs.Read(tmpbyte,0,tmpbyte.Length);
fs.Close();
Response.BinaryWrite(tmpbyte);
//Response.Flush();
//Response.ContentType = ct;
Response.End();
通过测试发现Response.AppendHeader("Content-Disposition","attachment; filename="+Path.GetFileName(strFile)); 这段代码加上,在其他机器上访问就返回到登录页面了,但这段代码在本机上用没有问题!这是什么原因啊?
如果在,EVERYONE僅表示域內的所有人.
if(!System.IO.File.Exists(strFile))
{
Response.Write("<script language='javascript'>alert('对不起,文件不存在!');</script>");
return;
}
Response.Clear();
Response.ClearHeaders();
Response.Charset = "GB2312";
Response.ContentEncoding =System.Text.Encoding.UTF8;
Response.ContentType = "application/octet-stream";
FileInfo fi=new FileInfo(strFile);
Response.AddHeader("Content-Disposition","attachment; filename=" + HttpUtility.UrlEncode(fi.Name)) ;
Response.AddHeader("Content-Length",fi.Length.ToString());
byte[] tmpbyte=new byte[1024*8];
FileStream fs=fi.OpenRead();
int count;
while((count=fs.Read(tmpbyte,0,tmpbyte.Length))>0)
{
Response.BinaryWrite(tmpbyte);
Response.Flush();
}
fs.Close();
Response.End();楼主用这段代码试一下
<identify impersonate=true username="domain\username" password="**" />