Upload completed with error on some files where canceled

Sep 27, 2010 at 6:56 AM
Edited Sep 27, 2010 at 7:04 AM

When i run the TestClient sample it works nicely

but when i implemented Interlink library in my application, somehow it do not want to upload any file

now i'm stuck and  i don't know whats wrong... since i'm already following all codes and configurations in TestClient.Web project

i'm using IIS 7 with integration mode, and in my application, i'm creating WCF service with a basicHttpBinding configuration

here's the screenshot of upload error :

 

and this is my web.config :

 

<?xml version="1.0"?>

<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->

<configuration>

    <appSettings>
      <add key="UploadHandler" value="IsaacApp.Web.UploadHandler, IsaacApp.Web"/>
      <add key="DownloadHandler" value="IsaacApp.Web.DownloadHandler, IsaacApp.Web"/>
    </appSettings>

    <system.web>
      <customErrors mode="On"/>
      <compilation debug="true" optimizeCompilations="true" targetFramework="4.0" />
    </system.web>

    <system.webServer>
      <handlers>
        <add name="FileDownload" verb="GET,POST" path="FileDownload.ashx" type="HSS.Interlink.Web.FileDownload, HSS.Interlink.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=9907eb1ad38d3903"/>
        <add name="FileUpload" verb="GET,POST" path="FileUpload.ashx" type="HSS.Interlink.Web.FileUpload, HSS.Interlink.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=9907eb1ad38d3903"/>
      </handlers>
    </system.webServer>

    <system.serviceModel>

        <bindings>
          
          <basicHttpBinding>
            <binding name="PictureBinding" maxReceivedMessageSize="2000000" maxBufferSize="2000000">
              <readerQuotas maxArrayLength="2000000" maxStringContentLength="2000000"/>
            </binding>
          </basicHttpBinding>

          <!--HSSInterlink-->
          <customBinding>
            <binding name="IsaacApp.Web.FileAccessService.customBinding0">
              <binaryMessageEncoding />
              <httpTransport />
            </binding>
          </customBinding>
          <!--HSSInterlink-->
          
        </bindings>
      
        <behaviors>
            <serviceBehaviors>
              <behavior name="IsaacApp.Web.PictureServiceBehavior">
                <serviceMetadata httpGetEnabled="true"/>
                <serviceDebug includeExceptionDetailInFaults="false"/>
              </behavior>

              <!--HSSInterlink-->
              <behavior name="">
                <serviceMetadata httpGetEnabled="true" />
                <serviceDebug includeExceptionDetailInFaults="false" />
              </behavior>
              <!--HSSInterlink-->

            </serviceBehaviors>
        </behaviors>

        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
      
        <services>
          <service behaviorConfiguration="IsaacApp.Web.PictureServiceBehavior"
           name="IsaacApp.Web.IsaacWCFService">
            <endpoint address="" binding="basicHttpBinding" bindingConfiguration="PictureBinding"
             contract="IsaacApp.Web.IIsaacWCFService">
              <identity>
                <dns value="localhost" />
              </identity>
            </endpoint>
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
          </service>

          <!--HSSInterlink-->
          <service name="IsaacApp.Web.FileAccessService">
            <endpoint address="" binding="customBinding" bindingConfiguration="IsaacApp.Web.FileAccessService.customBinding0"
             contract="IsaacApp.Web.FileAccessService" />
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
          </service>
          <!--HSSInterlink-->
          
        </services>
      
    </system.serviceModel>
  
  
</configuration>

 

 

I'll apreciate any help... THANKS !

Coordinator
Sep 27, 2010 at 12:13 PM

Can you right click on one of the failed files and 'view info' to see what the specific error was?

Also, does the OnError method get called from your upload handler? Meaning does any of the upload requests actually make it to your upload file handler?

Try uploading just one file, and put a break point on the OnError method or any of the other methods to ensure the request to upload is actually communicating with the HTTPHandler.

Thanks for trying Interlink and posting your questions!

Sep 27, 2010 at 1:59 PM
Edited Sep 27, 2010 at 2:00 PM

thank you for your answer,

when i right click failed files, i got error message "The remote server returned an error: NotFound"

i put break points in all of methods in UploadHandler.cs and it didn't hit any ! but all of my WCF service works very well...

it seems that the client does not connected to httpHandlers... maybe it is because wrong setting in web.config but i don't know where,,,

i think it is not IIS 7 issue because the TestClient example works nicely

Coordinator
Sep 27, 2010 at 2:47 PM

OK lets rule out some basics.

1. Is the HSS.Interlink.Web.dll file located in the BIN folder
2. Can you navigate to the http://yourUrl/FileUpload.ashx

If #2 above fails, it's usually because your site is a subdomain. Meaning the url to your site is http://domain.com/yoursite versus http://domain.com

If so, then you need to set the UploadFileDialog UploadUri property to be /yoursite/fileupload.ashx versus it's default of /fileupload.ashx

var udialog = new UploadFileDialog(GetMetadata);
udialog.UploadUri = "/yoursite/fileupload.ashx"
udialog.Show()
Sep 28, 2010 at 7:22 AM

there is one problem again

i tried to modifying your TestClient from classic pipeline mode to integration mode... replacing httpHandlers tag into handlers

and it does not work at all...

i'm using Visual Studio 2010, SL 4, Windows 7, and debugging using IIS 7.5

Coordinator
Sep 28, 2010 at 11:34 AM

Where you able to resolve your first issue?

As far as integration mode and handler comment, I need more information in order to provide assistance.

Nov 19, 2010 at 10:52 AM

I am having the exact same issue. W7 x64 iis 7.5. I followed the Quick Start Guide. I have the HSS.Interlink.Web.dll in my BIN folder and I am not running this in a subdomain enviroment.

Please let me know if I have any mistakes. Thanks!

WEB CONFIG

<?xml version="1.0"?>

<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->


<configuration>
  <appSettings>
    <!-- This value must match the Full TypeName including the namespace of your UploadHandler -->
    <add key="UploadHandler" value="SLFileUploadTest.Web.UploadHandler, SLFileUploadTest.Web"/>
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.0" />
    <httpHandlers>
      <add verb="GET,POST" path="FileUpload.ashx" type="HSS.Interlink.Web.FileUpload, HSS.Interlink.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=9907eb1ad38d3903" />
    </httpHandlers>
  </system.web>
</configuration>

UPLOADHANDLER.VB

Imports System.Diagnostics
Imports System.IO
Imports HSS.Interlink.Web

Namespace SLFileUploadTest.Web
    Public Class UploadHandler
        Inherits HSS.Interlink.Web.BaseUploadHandler
        Private fileStoreUri As String = "MyUploads"

        Public Sub New()
        End Sub

        Private Function GetFilePath() As String
            Return Path.Combine(Me.GetFolder(fileStoreUri), Me.FileName)
        End Function

#Region "BaseUploadHandler Members"

        Public Overrides Function CheckFileExists() As Boolean
            Dim file__1 As String = GetFilePath()
            Return File.Exists(file__1)
        End Function
        Public Overrides Function CreateNewFile() As Responses
            Dim file__1 As String = Me.GetFilePath()
            Try
                If File.Exists(file__1) Then
                    File.Delete(file__1)
                    ' Assumes you support file overwrite.
                End If
            Catch
            End Try

            File.Create(file__1).Close()

            Return HSS.Interlink.Web.Responses.Success
        End Function
        Public Overrides Function AppendToFile(ByVal buffer As Byte()) As Responses
            Dim file__1 As String = GetFilePath()
            Using fs As FileStream = File.Open(file__1, FileMode.Append)
                fs.Write(buffer, 0, buffer.Length)
            End Using
            Return HSS.Interlink.Web.Responses.Success
        End Function
        Public Overrides Sub CancelUpload()
            Dim file__1 As String = Me.GetFilePath()
            Try
                If File.Exists(file__1) Then
                    File.Delete(file__1)
                End If
            Catch
            End Try
        End Sub
        Public Overrides Sub UploadComplete()
            ' Do something useful on completion.
        End Sub
        Public Overrides Function IsAuthorized() As Boolean
            Return True
        End Function
        Public Overrides Sub OnError(ByVal ex As System.Exception)
            Debug.WriteLine(ex.ToString())

            ' clean up partial file
            Dim file__1 As String = Me.GetFilePath()
            Try
                If File.Exists(file__1) Then
                    File.Delete(file__1)
                End If
            Catch
            End Try
        End Sub
#End Region
    End Class
End Namespace

MAINPAGE.XAML.VB
Partial Public Class MainPage
    Inherits UserControl

    Private Sub Button_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
        Dim udialog = New HSS.Interlink.UploadFileDialog()
        udialog.MaxFileSizeKB = Integer.MaxValue
        udialog.AllowFileOverwrite = True
        udialog.BrowseAndShow()
    End Sub
End Class
Coordinator
Nov 19, 2010 at 8:16 PM

Nothing has changed in this release. Does it work in your develoment environment? It may be something on the IIS Machine/Software Config. I know the Handlers can be problematic for some. I'm running this on three different servers for three different applications as well as two external customer installations and no issues. All Win2008 x64 IIS7.5 in integration mode and have no custom config beyond the demo code and config.

Jun 1, 2015 at 2:42 PM
Edited Jun 1, 2015 at 2:49 PM
Incase someone encountered the same issue. I have this issue and my solution is below.

Issue reproduce:
  • Download the original example source from CodePlex
  • Unzip and try to uplaod a txt file, then there's an error: Upload completed with error on some files where canceled
  • In my case, the job file's last-access-time-UTC is not working as expected. (HSS.Interlink.Web/BaseHandler.cs, Line: 233)
Test Environment:
OS: Win XP SP3
Time Zoon: UTC+8
.Net Framework: v4.0
Silverlight: v4

Solution to my case:
  • Open the HSS.Interlink.Web source project
  • In file BaseHandler.cs, Method: PurgeTempFiles(string folder), Line: 233
  • Change the fi.LastAccessTimeUtc to fi.LastWriteTimeUtc
  • Rebuild the HSS.Interlink.Web project and reference the new HSS.Interlink.Web.dll
  • Everything should be fine now.
Please refer to image below for more info:
Hss-Error-LastAccessTimeUtc