.zip 파일을 다운로드하는 데 webmethod를 사용하고 있지만 파일을 다운로드 할 수 없습니다. 오류없이 잘 실행 내 코드는 코드는 다음과 같습니다 : 내가 VS2008 모든 솔루션 감사를 사용하고
파일이 웹 메서드에서 다운로드되지 않았습니다.
[WebMethod]
public static void DownloadExtension(string ExtensionPath)
{
string filepath = HttpContext.Current.Server.MapPath(ExtensionPath);
FileInfo file = new FileInfo(filepath);
if (file.Exists)
{
HttpContext.Current.Response.ClearContent();
HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name);
HttpContext.Current.Response.AddHeader("Content-Length", file.Length.ToString());
HttpContext.Current.Response.ContentType = ReturnExtension(file.Extension.ToLower());
HttpContext.Current.Response.TransmitFile(file.FullName);
HttpContext.Current.Response.End();
}
}
private static string ReturnExtension(string fileExtension)
{
switch (fileExtension)
{
case ".zip":
return "application/zip";
default:
return "application/octet-stream";
}
}
. u는이 method..it을 시도 할 수 있습니다