Re: [izwebfilemanager] download issue

97 views
Skip to first unread message

Igor Zelmanovich

unread,
Nov 5, 2014, 1:48:57 AM11/5/14
to izwebfil...@googlegroups.com
Download and Open actions have different implementation.

Open action makes browser access the file directly. In this case, IIS handle request to static file and use configured identity for authentication,

In case of download, ASP.NET code play a part. In this case identity configured running application pool is used for authentication. According the log, it is APPPOOL\UAEACPortal

You can either grant access permission for app pool identity or use impersonate configuration in Web.config (http://msdn.microsoft.com/en-us/library/72wdk8cc(v=vs.85).aspx)





On Tue Nov 04 2014 at 10:56:49 PM Wasim Fadloun <wasimf...@gmail.com> wrote:
thank you for the excellent control.
I have a problem with the download function.
my virtual directory refers to network location ( on another server ) and I am authenticating the user when opening the page.
the control displays the folders properly and the user can access only the folders he authorized to (so far so good) , user can do almost all the function  ( rename,delete, move and copy) but the download.
when trying to download the file the following error occurs
The handle is invalid. (Exception from HRESULT: 0x80070006 (E_HANDLE)) 

if I give permission on the folder for everyone , the download works.
so I think I am stuck here with permission issue !!??, the user 100% has the right permission to read the file , and if I put the full path to the file in the addressbar the browser downloads it with no issue.

in the event viewer I am getting the following 
Event code: 3005 
Event message: An unhandled exception has occurred. 
Event time: 11/4/2014 12:31:32 PM 
Event time (UTC): 11/4/2014 8:31:32 PM 
Event ID: f0ecf106725f433db84813f76b24e26b 
Event sequence: 42 
Event occurrence: 1 
Event detail code: 0 
 
Application information: 
    Application domain: /LM/W3SVC/1/ROOT/Share-2-130596066846124288 
    Trust level: Full 
    Application Virtual Path: /Share 
    Application Path: C:\inetpub\wwwroot\Portal\Share\ 
    Machine name: SRV-DMZ1 
 
Process information: 
    Process ID: 3180 
    Process name: w3wp.exe 
    Account name: IIS APPPOOL\UAEACPortal 
 
Exception information: 
    Exception type: COMException 
    Exception message: The handle is invalid. (Exception from HRESULT: 0x80070006 (E_HANDLE)) 
 
Request information: 
    Request path: /share/default.aspx 
    User host address: 172.30.0.4 
    User: UAEAC\sham 
    Is authenticated: True 
    Authentication Type: Basic 
    Thread account name: IIS APPPOOL\UAEACPortal 
 
Thread information: 
    Thread ID: 5 
    Thread account name: IIS APPPOOL\UAEACPortal 
    Is impersonating: False 
    Stack trace: 
 
 
can you help please
thanks

--
You received this message because you are subscribed to the Google Groups "izwebfilemanager" group.
To unsubscribe from this group and stop receiving emails from it, send an email to izwebfilemanag...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Wasim Fadloun

unread,
Nov 5, 2014, 7:13:01 AM11/5/14
to izwebfil...@googlegroups.com
Thanks I  will try the proposed fix, and let you know

Wasim Fadloun

unread,
Nov 6, 2014, 1:29:04 AM11/6/14
to izwebfil...@googlegroups.com
Hi,

unfortunately, that did not work for my case.
impersonate another user effects the logged user permission.
for your record I have done the following :
  • place 2 buttons on a webpage that has the izwebfilemanager
  • Button1 uses the same code you use in the source code to download izwebfilemanager(selectedfile)
  • Button2 uses the following code 
Response.ClearContent()
Response.AddHeader("Content-Disposition", "attachment; filename=" + File.Name)
Response.AddHeader("Content-Length", File.Length.ToString())
Response.TransmitFile(File.FullName)
Response.Flush()

on testing , button1 gave the same error that generated by the izfilemanager, where button2 downloaded the file with no issue.
I think things will get solved if you recode the download block.
I tried to do that but the project gives tens of errors when open it on vs2012 ( I am pretty new to Typescript stuff ).

let me know what you think.

thanks 
wasim

Igor Zelmanovich

unread,
Nov 6, 2014, 9:34:12 AM11/6/14
to izwebfil...@googlegroups.com
I can change the code and build the project, but I cant apply your code.
What does 'File' refers to? If it is System.IO.File, how do you create the instance? 
Current code I use is:

        void RaisePostBackEvent(string eventArgument)
        {
            var args = eventArgument.Split(new[] { ':' });
            FileManagerItemInfo fmi = ResolveFileManagerItemInfo(DecodeURIComponent(args[1]));
            switch (args[0])
            {
                case "Download":
                    var e = new DownloadFileCancelEventArgs() { DownloadFile = fmi };
                    OFileDownload(e);
                    if (!e.Cancel)
                    {
                        string file = fmi.PhysicalPath;
                        if (File.Exists(file))
                        {
                            Page.Response.Clear();
                            Page.Response.ContentType = "application/octet-stream";
                            Page.Response.AddHeader("Content-Disposition",
                                                    "attachment;filename=" + EncodeURIComponent(Path.GetFileName(file)));
                            Page.Response.TransmitFile(file);
                        }
                        Page.Response.End();
                    }
                    break;
                case "ExecuteCommand":
                    OnExecuteCommand(fmi, args[2], args[3]);
                    break;
            }
        }
Can you applay changes you suggest and send me your version?

Igor Zelmanovich

unread,
Nov 6, 2014, 9:36:29 AM11/6/14
to izwebfil...@googlegroups.com
There is easiest way to solve the issue. IZWebFileManager has FileDownload event. You can just handle it and override default behaviors.

To unsubscribe from this group and stop receiving emails from it, send an email to izwebfilemanager+unsubscribe@googlegroups.com.

Wasim Fadloun

unread,
Nov 6, 2014, 2:04:36 PM11/6/14
to izwebfil...@googlegroups.com
the revised version will be like this
     void RaisePostBackEvent(string eventArgument)
       
{
           
var args = eventArgument.Split(new[] { ':' });
           
FileManagerItemInfo fmi = ResolveFileManagerItemInfo(DecodeURIComponent(args[1]));
           
switch (args[0])
           
{
               
case "Download":
                   
var e = new DownloadFileCancelEventArgs() { DownloadFile = fmi };
                   
OFileDownload(e);
                   
if (!e.Cancel)
                   
{
                       
string file = fmi.PhysicalPath;
                       
if (File.Exists(file))
                       
{

                           
FileInfo File2Download = new FileInfo(file);
                           
Page.Response.ClearContent();
                           
Page.Response.AddHeader("Content-Disposition", "attachment; filename=" + File2Download.Name );
                           
Page.Response.AddHeader("Content-Length", File2Download.Length.ToString());
                           
Page.Response.TransmitFile(file);
                       
}
                       
Page.Response.Flush();

                   
}
                   
break;
               
case "ExecuteCommand":
                   
OnExecuteCommand(fmi, args[2], args[3]);
                   
break;
           
}
       
}

I got things solved by override the FileDownload event.
Thank you
-wasim
To unsubscribe from this group and stop receiving emails from it, send an email to izwebfilemanag...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages