Unable to determine the UploadHandler

Jun 29, 2011 at 4:00 PM

Hi,

We're having a problem with upload feature and may be you can help us.

When we click upload, a message appear with "Upload completed with errors ..." The error is: "The remote server returned an error: NotFound."

The fiddler session to (http://localhost/SLUploadTest.Web/FileUpload.ashx?u=MDYvMjkv...) return error 500: Unable to determine the UploadHandler

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

 

Environment

Win7 + IIS 7.X with Integrated Pipeline +  AppPool is running the site set to .NET 4.0 and set to Integrated Mode + Net Trust Levels: Full

 

Web.config:

<?xml version="1.0" encoding="UTF-8"?>

<configuration>
  <system.webServer>
    <handlers>
      <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.web>
    <compilation debug="true" optimizeCompilations="true" targetFramework="4.0" />
    <customErrors mode="Off" />
  </system.web>

  <appSettings>
    <add key="UploadHandler" value="SLUploadTest.Web.UploadHandler, SLUploadTest.Web"/>
  </appSettings>
  
</configuration>

Main page code:
Private Sub Button1_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles Button1.Click
        Dim udialog = New HSS.Interlink.UploadFileDialog()
        udialog.MaxFileSizeKB = Integer.MaxValue
        udialog.AllowFileOverwrite = True
        udialog.UploadUri = "http://localhost/SLUploadTest.Web/FileUpload.ashx"
        udialog.BrowseAndShow()
End Sub

 

UploadHandler Code:

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

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

        Public Sub New()
            PurgeInterval = 660
            'TempFolder = "C:\Users\UserPC\Documents\Visual Studio 2010\Projects\SLUploadTest\SLUploadTest.Web\MyUploads"
        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(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(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

Jun 29, 2011 at 9:13 PM

1A. Is the deployed Web Application a sub app under the Default Web Site in IIS?

i) if it is then the URI you are specifying doesn't appear to be legitimate.
ii) if it's not, then the URI is definitely incorrect.

Example:

http://localhost/fileupload.ashx would be the default URI if the Web Application is not a Sub Web-Site under the Default Web Site
http://localhost/mysite/fileupload.ashx would be a custom URI if the Web Application is a Sub Web-Site under the Default Web Site (note: mysite is the Sites Name, not its physical path)

1B. The HttpHandler path must match the web site url pathing

Example:

fileupload.ashx would be the default path if the Web Application is not a Sub Web-Site under the Default Web Site
mysite/fileupload.ashx would be a custom path if the Web Application is a Sub Web-Site under the Default Web Site (note: mysite is the Sites Name, not its physical path)

3. Ensure the AppPool Identity has the ability to create folder/files in the web sites directory and that your apps root folder is not readonly.

Once you confirm these issues, re-test and let me know if you get it worked out...

Jun 30, 2011 at 1:26 AM

Thank you very much for all your help.

This company is the best and has the best support team.

Really great people.

 

Jul 12, 2012 at 4:45 PM

Project with lightswitch
ISS 6.0
Win Server 2003
HSS.Interlink ver 2.2

upload works fine in development but after the publish i get the following error:

if i run the LS app on the server browser:
al works fine and then "download complete with errors"
[HttpWebRequest_WebException_RemoteServer]
Arguments: NotFound
Debugging resource strings are unavailable. Often the key and arguments provide sufficient information to diagnose the problem. See http://go.microsoft.com/fwlink/?linkid=106663&Version=5.1.10411.0&File=System.Windows.dll&Key=HttpWebRequest_WebException_RemoteServer

if i run it on another pc browser in network:
al works fine and then "download complete with errors"
The remote server returned an error: NotFound.

i tried playing with the following:

d = New UploadFileDialog()
d.UploadUri = "http://bg106/mmanufacturers/FileUpload.ashx" and tried "/FileUpload.ashx" also without/

and changed the webconfig to:
<add verb="GET,POST" path="MManufacturers/FileDownload.ashx" type="HSS.Interlink.Web.FileDownload, HSS.Interlink.Web" />
<add verb="GET,POST" path="MManufacturers/FileUpload.ashx" type="HSS.Interlink.Web.FileUpload, HSS.Interlink.Web" />

checked folder permissions of the FileStoreFolder

and al lot of other tries from this forum ... but nothing seem to be working.
it seems that i can't reach the fileupload.ashx.

am i missing something?

Jul 12, 2012 at 4:52 PM

In you web config change the path from "MManufacturers/FileUpload.ashx" to "/MManufacturers/FileUpload.ashx"

And on the client

A: ITB - you can just use "fileupload.ashx"
B: OOB - you have to use an absolute URL (http://bg106/mmanufacturers/FileUpload.ashx)

Jul 14, 2012 at 12:17 PM
Edited Jul 14, 2012 at 1:32 PM

Thank you for the great directions ... tried it and it didn't work ...

so i removed: d.UploadUri = "http://bg106/mmanufacturers/FileUpload.ashx" from the createDialog code and after publishing changed the web.config from "FileUpload.ashx" to "/MManufacturers/FileUpload.ashx"

And now it works ... BUT it only works from any pc in the network.

if i try it from the IIS server itself, i get the same error msg ...
[HttpWebRequest_WebException_RemoteServer]
Arguments: NotFound
Debugging resource strings are unavailable. Often the key and arguments provide sufficient information to diagnose the problem. See http://go.microsoft.com/fwlink/?linkid=106663&Version=5.1.10411.0&File=System.Windows.dll&Key=HttpWebRequest_WebException_RemoteServer

Tried it from a pc outside the network (via the internet) an got the same error msg ...

The issue: publish with following code change and no changes in webconfig

 d.UploadUri = http://mmtest.dyndns.org:1050/mmanufacturers/FileUpload.ashx AND IT WORKS on the internet and internal network

now i'm looking for a solution that will work even from another link. because the LSapp will run insite an Amlog portal.

Thanks again for the GREAT support!

Jul 14, 2012 at 4:41 PM

FOUND IT!!!

What works for me in every way:

- NO CHANGES IN THE web.config

- In code change d.UploadUri = "/MManufacturers/FileUpload.ashx"

Thanks again for the GREAT support!

Jul 17, 2012 at 3:29 AM

Glad to hear you got it working.

Nov 14, 2012 at 9:14 AM

I'am back again ;)

I' reinstalled the win server 2003 with the same settings as above

Published the unchanged lightswitch app, everything seems to work except the upload returns:

[HttpWebRequest_WebException_RemoteServer]

Arguments: NotFound

Debugging resource strings are unavailable. Often the key and arguments provide sufficient information to diagnose the problem. See http://go.microsoft.com/fwlink/?linkid=106663&Version=4.1.10329.0&File=System.Windows.dll&Key=HttpWebRequest_WebException_RemoteServer

I set permissions of the upload folder to full control for IISUser, Network, NetworkService ... same error

I set properties of the upload folder to read and write but still same error ... what am i doing wrong???

Nov 14, 2012 at 10:04 AM

FOUND IT!!!

You also need to set the permissions of the "Default Web Site" -> "network service" account