Works in root directory only

May 29, 2009 at 11:36 AM

Hi,

Firstly, thanks for putting this project on Codeplex. It looks like exactly what I'm looking for.

I tried implementing it within my app but keep getting upload errors (Not Found). It seems the UploadControlHandler.ashx isn't getting found (debug points aren't getting hit in it's BeginRequest).

I've checked that the UploadHandlerPath init param is correct.

I decided to create a new test web app project which references your Vci.FileUploader assembly to rule out anything my app could be doing.

I copied your SilverlightFileUploader.Web website structure and sure enough it worked.

Then I tried moving TestPage.aspx and UploadControlHandler.ashx into a folder named "test". I changed the UploadHandlerPath to reflect this "~/test/UploaderControlHandler.ashx" and now I'm getting the same "Not Found" error for UploadControlHandler.ashx (the one you get in the Silverlight error tooltip).

I'm afraid my knowledge of Silverlight isn't progressed enough to know what the problem is or to effectively diagnose it. Could you shed any light on this?

Regards,

Ed

Jun 9, 2009 at 9:31 PM
Edited Jun 9, 2009 at 11:54 PM

I am also running into this issue. I tried updating the only reference to the UploadControlHandler.ashx I could find, without luck. Both the TestPage.aspx/cs and UploadControlHandler.ashx/cs files must be in the root directory together.

Thanks for some newbie Silverlight direction!

Coordinator
Jun 18, 2009 at 6:05 PM

I was not aware that using a .ashx file would only work at the root of the web!

I actually don't use a direct .ashx file very often -- it's mainly just a convenience that microsoft has provided.  Here is another approach that should avoid the issue:

Move the code in UploaderControlHandler.ashx.cs to a class file in Vci.FileUploader, and then create a web.config entry to map a url to that class.  Here are detailed instructions:

1. Create a file called UploaderControlHandler.cs in Vci.FileUploader

2. Move the code from UploaderControlHandler.ashx.cs to UploaderControlHandler.cs -- the only changes that you need to make are the namespace, and you can remove the attributes from the class definition, so the top of the file will look like this:

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using System.Web;

using Vci.Core;

namespace Vci.FileUploader
{
    public class UploaderControlHandler : IHttpAsyncHandler
    {
...

...

 

3. Create web.config entries to map UploaderControlHandler.ashx to this class.  There are 2 places that you'll want to add it, to support different versions of IIS.  The first is in <system.web>/<httpHandlers>:

<httpHandlers>
   (you'll see the a few default handlers defined here)
  <add verb="*" path="UploaderControlHandler.ashx" type="Vci.FileUploader.UploaderControlHandler,Vci.FileUploader"/>
</httpHandlers>

The 2nd is in <system.webServer>/<handlers>:

<handlers>
  (you'll see a bunch of default handlers defined here)
  <add name="UploaderControlHandler.ashx_*" path="UploaderControlHandler.ashx" verb="*" type="Vci.FileUploader.UploaderControlHandler,Vci.FileUploader" preCondition="integratedMode,runtimeVersionv2.0"/>
</handlers>

That should do it!  It'll use the same url as before, but you've explicitly set up a mapping to the class that defines the http handler.  I will check in a version that uses this approach shortly, and update the documentation on this site.

 

 

Jun 21, 2009 at 1:33 AM

I downloaded the latest version, and it already had the web config and the class re-org listed above. Unfortunately, it still only worked in the root directory.

However, I was able to get it working (on /test/ in addition to the root directory) by adding the bolded code on line 54 of HttpFileUploader.cs (right before the UriBuilder is newed up):

  httpHandlerPath = Application.Current.Host.Source.LocalPath.Substring(1, 
                Application.Current.Host.Source.LocalPath.LastIndexOf("/ClientBin/"))
                + httpHandlerPath;

Mr. Coley, excellent job on this project, it was exactly what I was looking for!

Thanks,

Aeren

 

Coordinator
Jun 22, 2009 at 10:15 AM

Good catch -- I think that I see the problem now!  UploaderControl was not properly passing the URL for the http handler to the Silverlight object.

I have checked in a new version that should resolve this issue.  I have also parameterized some of the paths to facilitate using the example code from any location.

UploaderControl now has the following 3 properties:

  1. ScriptPath - path to the provided uploadercontrol.js, defaults to ~/scripts/uploadercontrol.js
  2. XapPath - path to the .xap file for the Silverlight control, defaults to ~/ClientBin/SilverlightFileUploader.xap
  3. HandlerPath - path to the http handler that will receive the uploaded files, defaults to ~/UploaderControlHandler.ashx

"~" can be used to denote the application root path.

 

These should allow you to place the javascript and xap file wherever you want, and they will allow you to control the path to the provided http handler (or use UploaderControl to reference your own http handler).

I will update the documentation to reflect these changes shortly.

Jan 30, 2010 at 6:19 PM
Edited Feb 1, 2010 at 1:45 PM

i have been having an issue with this lately and found that when I add a <system.diagnostics> section to my web.config, it causes this error to come up. The only listener I have in this section is an eventlogTraceListener. Then I get a FileNotFound errror in the control - when looking for the handler file. I remove this section from the web config, and it works fine. Any Ideas?

EDIT

I found that it happens to be the threadPool that I implemented. I am working on a fix since it appears to be a permissions issue with the thread and my Event Log Listener...

Mar 15, 2010 at 11:33 AM
Edited Mar 15, 2010 at 1:37 PM

Hi,

Can somebody tell me where is the file "UploaderControlHandler.ashx" located? I have only "UploaderControlHandler.cs".
I am trying integrate control with MVC an d it gives the same NotFound Error. Any suggestions? 

Thanks in Advance..