Quick Start problem

Mar 9, 2011 at 4:44 PM

Greetings,

I am having a problem trying to get a simple upload/download working.  I tried the quickstart sample, and it gets as far as selecting the file to upload and then pressing "upload".  At this point I get an error stating "Upload completed with errors or some files were canceled.", and the progress stays at 0%.

I think I must be missing something in the code or setup.  I have the latest version installed.  Below is a snippet of my Web.config:

<appSettings>
    <!-- This value must match the Full TypeName including the namespace of your UploadHandler -->
    <add key="UploadHandler" value="SLFileTest.Web.UploadHandler, SLFileTest.Web"/>
    <add key="DownloadHandler" value="SLFileTest.Web.DownloadHandler, SLFileTest.Web"/>
  </appSettings>

  <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>

The other area where I am a bit confused is how to specify the "fileStoreUri" in both the UploadHandler and DownloadHander classes.  Do I need to indicate the name of the Web application along with the directory or folder where I want the files to reside on the server?  Or do I just indicate the directory name within the Web application without the app name?  Or does this have to be a full path?

namespace SLFileTest.Web
{
    public class UploadHandler : HSS.Interlink.Web.BaseUploadHandler
    {
        string fileStoreUri = @"SLFileTest/documents";


Any help would be appreciated!

Thanks,

Abby

Coordinator
Mar 9, 2011 at 8:47 PM

1. Quickstart...

Make sure the project namespaces match your actual implementation. Another frequent challenge some user run into, is the client the default URI to the Upload Handler is "/FileUpload.ashx" which is a relative URI to your application root, but if you're running within a nested application (http://domain.com/app versus http://domain.com ) you will need to set the Upload Uri on the client to include your nested app. Example: "app/FileUpload.ashx". Beyond that it should work out of the box as is based on the quick start.

2. FileStoreUri

To clarify your upload handler is your implementation to save the file server side. So in the example provided the fileStoreUri is just a convenience variable of where to save the upload files to and uses a base class method called GetFolder which will automatically create the folder if doesn' already exist, relative to the application folder. For example if you application is running c:\inetpub\wwwroot\ and your call GetFolder("Test/Documents"), it will create and return the path the a folder with the following path "c:\inetpub\wwwroot\test\documents". Again it's just a convenience method, but you could save the contents to disk or database anyway you desire.

If you still have trouble let me know, more than happy to assist.

Mar 10, 2011 at 3:46 PM

Thanks for the quick reply!

I guess I am still missing something.  I tried to run the Quickstart upload example exactly as presented on the website, but with my namespace "SLFileTest.Web" instead of "SLFileUploadTest.Web".

I adjusted the Web.config file to use "SLFileTest.Web" as well, but left  path="FileUpload.ashx"  in the handlers as is.  When I ran it, I could select a file to upload, but it gave an error and did not complete.

If I understand your explanation correctly, this should have created a new folder as follows:  "C:\inetpub\wwwroot\MyUploads"   with the selected file stored in MyUploads. 

All this assumes that I make no changes to the Quickstart example.  However I did not see a new folder being created.  I also tried to first create a new folder (C:\inetpub\wwwroot\MyUploads) and open up the permissions, but still got the same error.

I have also tried to run a simple Download, by first creating a DownloadHandler.cs, then adding code for a button.  Below is the code for the Button_Click, where I am using the open file inline.

// Download
private void Button_Click(object sender, RoutedEventArgs e)
{
   string fileName = "test.pdf";

   DownloadFileDialog.OpenFileInline(fileName);
}

This produced a 404 error as follows:

Server Error in '/' Application.

The resource cannot be found. 
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  
Please review the following URL and make sure that it is spelled correctly. Requested URL: /FileDownload.ashx In the end, I really don't care that much whether I store the uploaded/downloaded files in a directory off of "C:\inetpub\wwwroot\MyUploads", or
within my web application folder (ie. C:\inetpub\wwwroot\SLFileTest\documents").

If you have any other ideas, I would appreciate it.
Thanks again for trying to help me.
Abby

Mar 10, 2011 at 9:46 PM

I saw that in the thread, "Problems with quick start example", user "rdamske" said that he finally resolved his problem (similar to mine),

by making sure that the application was configured properly.  I would be happy to check these settings if I knew which ones were pertinent.

I have the latest HSS Interlink v 2.1.400 installed, with Visual Studio 2010 Professional, latest Silverlight 4, and .NET Framework 4. 

I am using IIS 7 on Windows 7 and have the SLFileTest application deployed to the ApplicationPool with ASP.NET v4.0 in Integrated Pipeline mode.

Are these settings correct for HSS Interlink?

Thanks,

Abby

Coordinator
Mar 11, 2011 at 1:39 PM

To confirm, the quickstart is based on these assumptions...

  • This assumes Visual Studio 2010 and .NET 4.0, and running in debug mode from the IDE.
  • Download and install HSS Interlink
  • Create a new Silverlight Application with the following name "SLFileUploadTest" (hosted with a Web Site Application "SLFileUploadTest.Web").
  • Add a reference to HSS.Interlink.Web for the Web Site App
  • Add a reference to HSS.Interlink to the SL App
  • Add a reference to System.Windows.Control to the SL App

    From the Documentation - http://interlink.codeplex.com/documentation , I think this will solver your problem:

    Http Handlers

    HSS Interlink by default provides the necessary HTTP Handlers to receive and process requests. You must specify the HTTP Handler by creating handler mappings in your web config.
    You can also specify different handler Uri's but the HSS Interlink Client assumes FileUpload.ashx and FileDownload.ashx as the defaults.

    You can specify more than one instance of the same handler by specifying different HSS Interlink .NET Types. You can also specify either the Sync or Async by specifying
    either HSS.Interlink.Web.FileDownloadAsync or HSS.Interlink.Web.FileDownload as the handlers Type.

    For IIS 7.X with Integration Mode, specify the handler in the <system.webServer> config section:

    <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>
    


    For IIS 7.X with Classic Mode, older versions and debugging with VStudio Dev Web Server (Cassini) use the following in the <system.web> config section

    <httpHandlers>
        <add verb="GET,POST" path="FileDownload.ashx" type="HSS.Interlink.Web.FileDownload, HSS.Interlink.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=9907eb1ad38d3903" />
        <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>
    

    For more detail from MSDN see this article here

  • Coordinator
    Mar 11, 2011 at 1:46 PM

    Here some information from the documentation and may help further clarify: see the documentation for complete details.

    File Handlers
    You specify your custom file handler by creating an appSetting entry as follows.
    For a single HttpHandler as defined above you can have one or more file handlers. From the Interlink client, you specify which handler
    should handle your download request.

    NOTE: The value of the appSetting is the Qualified Assembly Type Name.

    interlink_download9.png

    So we've completed our download handler and are ready to begin serving download requests, now let's implement our upload handler.

    Upload Handler

    The upload handler has a built in protocol where by we call a few different methods to receive a file.

    The protocol is:

    1. IsAuthorized - is called for each communication step within the process
    2. CheckFileExists - this method is called once in the beginning to confirm it's ok to upload this file and optional supports overwrite
    3. CreateNewFile - this method is called to begin the upload process by creating the (new empty) file
    4. AppendToFile - this method is called repeatedly to append one or more chunks of data to the file
    5. CancelUpload - this method is called once to signal the user has requested to cancel the upload, in which case you should delete the file
    6. UploadComplete - this method is called once to signal that the client is done sending all of it's chunks