ASP.NET jquery.uploadify上傳控件中文亂碼解決辦法
終於找到ASP.NET jquery.uploadify上傳控件中文亂碼解決辦法。整個asp.net網站用的gb2312的編碼,用uploadify上傳控件上傳中文時在IE能部分成功,FF,Chrome則完全失敗,查找了一天原因,網上介紹說uploadify的flash是採用utf-8的編碼方式,試過修改flash文件默認的編碼爲gb2312,結果還是不行。多翻測試原來可以這樣解決ASP.NET jquery.uploadify上傳控件中文亂碼問題,不多說了,直接講ASP.NET jquery.uploadify上傳控件中文亂碼解決辦法:
只需要在UploadHandler.ashx裏面直接加上命名空間using System.Text;和下面一句就可以了,也不用在config裏面去設置什麼
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
context.Request.ContentEncoding = Encoding.GetEncoding("UTF-8");
context.Response.ContentEncoding = Encoding.GetEncoding("UTF-8");
context.Response.Charset = "UTF-8";
ASP.NET jquery.uploadify上傳控件中文亂碼解決辦法。成功圖如下: