コード例 #1
0
ファイル: EditPassword.ashx.cs プロジェクト: ElcoTeam/Linuo
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            Action = RequstString("Action");

            if (Action.Length == 0)
            {
                Action = "";
            }


            if (Action == "EditPsw")
            {
                UserInfo userinfo = new UserInfo();
                userinfo.UserID      = RequstString("UserID");
                userinfo.OldPassword = RequstString("OldPsw");
                userinfo.NewPassword = RequstString("NewPsw");
                ResultMsg_User result = new ResultMsg_User();
                result = EditPsw(userinfo, result);
                context.Response.Write(jsc.Serialize(result));
            }
            else if (Action == "DownFlash")
            {
                FlashInfo flashInfo = new FlashInfo();
                flashInfo.FlashVersion = RequstString("CurrentAgent");

                DownLoadFlash(flashInfo, context.Response);
            }
        }
コード例 #2
0
ファイル: EditPassword.ashx.cs プロジェクト: ElcoTeam/Linuo
        public void DownLoadFlash(FlashInfo flashInfo, System.Web.HttpResponse Response)
        {
            var basePath = VirtualPathUtility.AppendTrailingSlash(HttpContext.Current.Request.ApplicationPath);

            string fileURL = "";

            if (flashInfo.FlashVersion == "Chrome")
            {
                fileURL = HttpContext.Current.Server.MapPath((basePath + "Login/Temp/flashplayerPPAPI_25.0.0.127.exe"));//文件路径,可用相对路径
            }
            else
            {
                fileURL = HttpContext.Current.Server.MapPath((basePath + "Login/Temp/flashplayerNPAPI_26.0.0.131.exe"));//文件路径,可用相对路径
            }

            try
            {
                FileInfo fileInfo = new FileInfo(fileURL);
                Response.Clear();
                Response.AddHeader("content-disposition", "attachment;filename=" + HttpContext.Current.Server.UrlEncode(fileInfo.Name.ToString())); //文件名
                Response.AddHeader("content-length", fileInfo.Length.ToString());                                                                   //文件大小
                Response.ContentType     = "application/octet-stream";
                Response.ContentEncoding = System.Text.Encoding.Default;
                Response.WriteFile(fileURL);
            }
            catch (Exception ex)
            {
                flashInfo.result = "failed";
                flashInfo.msg    = "下载失败! \n" + ex.Message;
            }
        }