반응형
한글로된 파일 다운로드할 때 한글 깨짐 현상 방지
public ActionResult Down(string txtFName, string pathURL, string compareHash)
{
try
{
string filePath = Server.MapPath(pathURL + txtFName);
string chkFilehash = cls_Common.gf_FileCompareHashData(txtFName);
if (chkFilehash != compareHash)
{
return Content(cls_Common.JScriptMsgRedirect(new string[] { "다운로드 파일이 위, 변조 되었습니다.", "history.back(-1);" }));
}
if (!System.IO.File.Exists(filePath))
{
return Content(cls_Common.JScriptMsgRedirect(new string[] { "파일이 없습니다.", "history.back(-1);" }));
}
//한글파일 깨짐 방지
string enCodeFileName = Server.UrlEncode(txtFName);
Response.AddHeader("content-disposition", "attachment; filename=" + enCodeFileName);
return File(pathURL + txtFName, "application/unknown", txtFName);
}
catch (Exception err)
{
return new HttpNotFoundResult();
}
}
반응형
'프로그래밍 > C# ' 카테고리의 다른 글
[C#] XML 데이터를 JSON 문자열로 파싱 (xml to json) (0) | 2017.07.24 |
---|---|
[C#] JSON 문자열 XML로 파싱 (json to xml) (0) | 2017.04.26 |
[C#] URL에서 원하는 부분만 잘라서 보자 (파라미터 제거) (0) | 2017.02.01 |
[C#] StringBuilder과 InnerHtml으로 서버단에서 HTML 작성 (0) | 2017.02.01 |
[C#] Request.ServerVariables 전체 값 확인 (URL, IP주소 등등) (0) | 2017.02.01 |