Return ZipFile in ASHX

268 views Asked by At

I have an ASHX file that receives some parameters (user and password). Using this parameters i need to send a zipfile as ASHX's result. I've written this code but when i open the downloaded zip, it appears to be corrupted.

Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest

    context.Response.Clear()

    context.Response.ContentType = "application/x-zip-compressed"



    Dim sLoginName As String = context.Request.QueryString("LOGIN_NAME")
    Dim sLoginPassword As String = context.Request.QueryString("LOGIN_PASSWORD")

    If (Not String.IsNullOrEmpty(sLoginName) And
        Not String.IsNullOrEmpty(sLoginPassword)) Then

        If (CheckLogin(sLoginName, sLoginPassword)) Then



            Dim sZipUpdatePath As String = String.Empty

            Dim sVersionToInstall As String = GetVersionToInstall(sLoginName, sLoginPassword)
            Dim sZipName As String = "UPDATE.zip"

            If (Not String.IsNullOrEmpty(sVersionToInstall) And
                Not String.IsNullOrEmpty(sZipName)) Then

                sZipUpdatePath = "~\Updates\" + sVersionToInstall + "\" + sZipName



                context.Response.TransmitFile(context.Server.MapPath(sZipName))


            End If

        End If

    End If

End Sub

How can solve it?

0

There are 0 answers