代码:protected void Page_Load(object sender, EventArgs e)
{
Response.ContentType = "image/jpeg";
Response.WriteFile(MapPath("~/upload/1.jpg"));
return;
}
xpsp3下IIS 时输出正常。但是使用 httpd-2.2.15-win32-x86-no_ssl 加打插件 mod_aspdotnet-2.2.0.2006-setup-r2 做服务器时报错。各位有什么解决办法?
标题:200 OK
错误提示:
OKThe server encountered an internal error or misconfiguration and was unable to complete your request.Please contact the server administrator, [email protected] and inform them of the time the error occurred, and anything you might have done that may have caused the error.More information about this error may be available in the server error log.
注:我是用上网本做服务器,自用的,最多也就几个人访问,不想装windows2003。但是XP下IIS连接数太少了,有时我一个人打开多几个页面时也会出现打不开的情况,所以用了装了个Apache HTTP Server。能解决XP这个连接数的问题这个问题也算是解决了。
byte[] buffer = new Byte[10000]; // Length of the file:
int length; // Total bytes to read:
long dataToRead; // Identify the file to download including its path.
string filepath = "DownloadFileName"; // Identify the file name.
string filename = System.IO.Path.GetFileName(filepath); try
{
// Open the file.
iStream = new System.IO.FileStream(filepath, System.IO.FileMode.Open,
System.IO.FileAccess.Read,System.IO.FileShare.Read);
// Total bytes to read:
dataToRead = iStream.Length; Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition", "attachment; filename=" + filename); // Read the bytes.
while (dataToRead > 0)
{
// Verify that the client is connected.
if (Response.IsClientConnected)
{
// Read the data in buffer.
length = iStream.Read(buffer, 0, 10000); // Write the data to the current output stream.
Response.OutputStream.Write(buffer, 0, length); // Flush the data to the HTML output.
Response.Flush(); buffer= new Byte[10000];
dataToRead = dataToRead - length;
}
else
{
//prevent infinite loop if user disconnects
dataToRead = -1;
}
}
}
catch (Exception ex)
{
// Trap the error, if any.
Response.Write("Error : " + ex.Message);
}
finally
{
if (iStream != null)
{
//Close the file.
iStream.Close();
}
}