hi i've deploy my website on the hosting that is shared onn which ii7 is running, my web application i build insinternet framwork 3.5, i've got a download button which i run this code to download selected file from server

code onclick event:

  try

            Is available)

                    Obvious()

                        Response.ContentType = ReturnExtension(System.IO.Path.GetExtension(file.Title))

                        Response.AppendHeader("Content-Disposition", "attachment filename=" + file.Title)

                        Response.TransmitFile(strRequest)

                        Response.Finish()

                        HttpContext.Current.ApplicationInstance.CompleteRequest()

                        //DownloadFile(file.FullName, file.Title)

                    

                    else

                    

                

                else

                

            

            catch(HttpException ex)

            

i've localy deploy my application on iis 6 which it's running fine,but on hosting that is shared server after i click button it givr following unhandle exception

Exception:

Server Error in '/muftp' Application.

The handle is invalid. (Exception from HRESULT: 0x80070006 (E_HANDLE))

Description: An unhandled exception happened throughout the execution from the current web request. Please evaluate the stack trace to learn more concerning the error and where it came from within the code.

Exception Particulars: System.Runtime.InteropServices.COMException: The handle is invalid. (Exception from HRESULT: 0x80070006 (E_HANDLE))

Source Error:

An unhandled exception was produced throughout the execution from the current web request. Specifics of the foundation and placement from the exception could be recognized while using exception stack trace below.

Stack Trace:

[COMException (0x80070006): The handle is invalid. (Exception from HRESULT: 0x80070006 (E_HANDLE))]

[HttpException (0x80004005): A mistake happened while interacting using the remote host. The mistake code is 0x80070006.]

   System.Web.Hosting.IIS7WorkerRequest.RaiseCommunicationError(Int32 result, Boolean throwOnDisconnect) +2737528

   System.Web.Hosting.IIS7WorkerRequest.FlushCore(Boolean keepConnected, Int32 numBodyFragments, IntPtr[] bodyFragments, Int32[] bodyFragmentLengths, Int32[] bodyFragmentTypes) +85

   System.Web.Hosting.IIS7WorkerRequest.FlushCachedResponse(Boolean isFinal) +392

   System.Web.HttpResponse.UpdateNativeResponse(Boolean sendHeaders) +922

   System.Web.HttpRuntime.FinishRequestNotification(IIS7WorkerRequest wr, HttpContext context, RequestNotificationStatus&lifier status) +159

Version Information: Microsoft .Internet Framework Version:2..50727.4211 ASP.Internet Version:2..50727.4205

kindly let me know why this error is occur.

This can be a code of Download.aspx

EDIT: Skipped the part concerning the page loading fine initially. I am not quite sure what's being passed in out of your querystring, but perhaps you have attempted using Server.MapPath? So rather than

System.IO.FileInfo file = new System.IO.FileInfo(strRequest)

you've

System.IO.FileInfo file = new System.IO.FileInfo(Server.MapPath(strRequest))

Tell me in the event that helps.