Exception "Error Not Found" thrown on upload

Feb 21, 2012 at 9:25 PM
Edited Feb 21, 2012 at 9:44 PM


After much reading I see that this error is not un-common; however I've tried all the solutions proposed and I still get the "not found exception" when I try to upload files in my application.

What's interesting is that I have uploaded the example project to a production server and it worked.
But when I upload my actual project which integrates the file uploader control, it gives the exception.
My project is a Silverlight application, and I invoke the FileUploaderControl in one of my child window:

    public partial class UploadFilesWindow : ChildWindow
        public UploadFilesWindow()
            Dictionary<String, String> p = new Dictionary<String, String> ();
            p["UploadedFileProcessorType"] = "Vci.FileUploader.ExampleFileProcessor,Vci.FileUploader";
            p["UploadHandlerPath"] = "/UploaderControlHandler.ashx";
            //p["FileFilter"] = "7-zip|*.7z";
In my web.config I have set the sandbox path, which exists and has write permissions,
and the section with the handlers:
    <!-- path to a folder where files will be uploaded; the web application must have write access to this folder -->
    <add key="SandboxPath" value="C:\inetpub\wwwroot\Test\Temp"/>

      <add verb="*" path="UploaderControlHandler.ashx" type="Vci.FileUploader.UploaderControlHandler,Vci.FileUploader"/>

      <add name="UploaderControlHandler.ashx_*" path="UploaderControlHandler.ashx" verb="*" type="Vci.FileUploader.UploaderControlHandler,Vci.FileUploader" preCondition="integratedMode,runtimeVersionv4.0"/>
The other difference is that I have a included the Silverlight File Uploader within my project,
but surely that can't make a difference when it's deployed.
E.g. instead of this:

I have
I'm pretty sure the issue is to do with the HTTP handler but I can't figure out why.
On the local machine if I navigate to http://localhost:52878/UploaderControlHandler.ashx I get:
"System.ArgumentNullException: Value cannot be null. Parameter name:
path2 at System.IO.Path.Combine(String path1, String path2) at
Vci.FileUploader.UploaderControlHandler.ProcessFile(Object State) in
MyApplication.Web\Vci.FileUploader\UploaderControlHandler.cs:line 52"
Which means the handler is found, and if I run the application locally it works.
I performed the same test on the production server both for the test project and my application.
Both of them responded the same way as above, except that when I went to try
and upload a file my application failed with the "Not Found" exception.
I feel like I'm very close to finally getting it working but I'm really out of ideas :(
Can anyone help ?
Feb 21, 2012 at 9:43 PM

Nevermind, I figured it out.

What I did was change the HttpFileUploader as follow:
At line 51:

            UriBuilder builder = new UriBuilder(Application.Current.Host.Source.Scheme, Application.Current.Host.Source.Host,                Application.Current.Host.Source.Port, httpHandlerPath);
            UploadUrl = httpHandlerPath;// builder.Uri.ToString();

As you  can see I'm just bypassing the UriBuilder.
Then I modified my class like this:

p["UploadHandlerPath"] = Application.Current.Host.Source.AbsoluteUri.Substring(0, Application.Current.Host.Source.AbsoluteUri.LastIndexOf("/ClientBin")) + "/UploaderControlHandler.ashx";

And it worked.