【发布时间】:2012-12-04 12:00:58
【问题描述】:
我遇到了一个问题,即在我的 ashx.cs 处理程序中,即使我上传图片,我总是得到 application/octet-stream 的内容类型。
我使用uploadify 进行上传,一开始我使用的是uploadify v2.1.0。我已经升级到uploadify 3.1。无论如何,我使用任一版本都会收到 application/octet-stream 作为 ContentType。
我了解到这可能是 Flash 播放器的问题,所以我使用 their uninstaller 卸载了 Flash,并尝试了 Flash Player 10.1.102.64 和 11_1r102_55_64bit,并尝试再次重新安装最新版本。所有三个版本都没有改变内容类型。
我使用过 Internet Explorer 8 和 9,没有任何变化。以及 Windows Server 2008 R2 64 位和 Windows 7 64 位。
我的.ashx 处理程序:
namespace HttpHandlers
{
public class UploadsHandler
: IHttpHandler
{
/// <summary>
/// Enables processing of HTTP Web requests by a custom HttpHandler that implements the <see cref="T:System.Web.IHttpHandler" /> interface.
/// </summary>
public void ProcessRequest(HttpContext context)
{
try
{
HttpPostedFile file = context.Request.Files["Filedata"];
string mimeType = file.ContentType; // always application/octet-stream
context.Response.ContentType = "text/plain";
context.Response.Write("success");
}
catch (Exception ex)
{
context.Response.ContentType = "text/plain";
context.Response.Write(ex.Message);
}
}
/// <summary>
/// Gets a value indicating whether another request can use the <see cref="T:System.Web.IHttpHandler" /> instance.
/// </summary>
/// <returns>true if the <see cref="T:System.Web.IHttpHandler" /> instance is reusable; otherwise, false.</returns>
public bool IsReusable
{
get
{
return false;
}
}
}
}
此时我没有想法...这在之前一直有效,直到 某些东西发生了变化,现在我正试图弄清楚是什么...
【问题讨论】:
-
可能是服务器 MIME 类型配置问题...
标签: c# asp.net flash mime-types uploadify