Assistance with Upload and SharePoint 2010

4 posts, 0 answers
  1. DogEars
    DogEars avatar
    79 posts
    Member since:
    Jun 2007

    Posted 22 Sep 2011 Link to this post

    I'm having a devil of a time getting this to work.

    I have a requirement to upload directly to a SP library, so I'm using the following code inside an UploadHandler.cs file:
    public class UploadHandler : RadUploadHandler
            public override void ProcessStream()
                if (this.IsFinalFileRequest())
                    string filename = this.Request.Form["RadUAG_fileName"];
                    string fullPath = @"C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\FileUploadSP\FileTemp\";
                    SPContext.Current.Web.AllowUnsafeUpdates = true;
                    FileStream fs = new FileStream(fullPath + filename, FileMode.Open);
                    SPContext.Current.Web.Files.Add("/UploadLibrary/" + filename, fs, true);
                    File.Delete(fullPath + filename);

    I have build this using 2 projects. One a SL project that holds the control and the other a blank SP solution. Mapped it to the layouts folder and deploying it to a local dev. It GACs the dll correctly and everything looks like it should work. However, it crashes on me every single time I browse to the .ashx file or when I click the upload button, boom.

    I was first getting a could not create type error, but I worked around that to make SP happy with the format. Now I get this error:
    Exception information:
        Exception type: HttpParseException
        Exception message: Exception of type 'System.Web.HttpParseException' was thrown.
    Request information:
        Request path: /_layouts/FileUploadSP/UploadHandler.ashx
        User host address: fe80::543f:cf7d:803d:6749WSS_Minimal
        User: CRMDEV\Administrator
        Is authenticated: True
        Authentication Type: NTLM
        Thread account name: CRMDEV\Administrator

    I know the .ashx file is fine because I set it up to read from a different helloworld type class. But whenever I go for the radupload it blows on me. From what I have read your upload implements the IHttpHandler, but I'm wondering if it does now? Am I just missing something simple here?

    Here is my .ashx for reference:
    <%@ Assembly Name="Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <%@ WebHandler Language="C#" Class="FileUploadSP.TestClass, FileUploadSP, Version=, Culture=neutral, PublicKeyToken=7c8e2c3ef53023ee" %>

    And finally my XAML for the control itself:
    <UserControl x:Class="FileUploadSL.MainPage"
        d:DesignHeight="300" d:DesignWidth="400">
        <Grid x:Name="LayoutRoot" Background="White">
    <telerik:RadUpload x:Name="RadUpload1"
                               UploadServiceUrl="/_layouts/FileUploadSP/UploadHandler.ashx" />

    This is SP2010 on Server 2008 R2 of course with SQL 2008 R2, if it matters at all.

    If anyone could give me any guidance on this I would appreciate it. I've been tearing my hair out all day and I could really use some help.

    I have made the entire project available here for someone from support to take a look at. Download Solution

  2. DogEars
    DogEars avatar
    79 posts
    Member since:
    Jun 2007

    Posted 23 Sep 2011 Link to this post

    I finally figured out how to turn off the custom error stuff, didn't know there was another web.config in the _layouts folder.

    So I'm receiving the following error:

    Could not load file or assembly 'Telerik.Windows.RadUploadHandler, Version=2011.2.712.35, Culture=neutral, PublicKeyToken=5803cfa389c90ce7' or one of its dependencies. The system cannot find the file specified.

    What do I need to do to get this resolved? Is there a specific .dll to GAC?
  3. DevCraft banner
  4. DogEars
    DogEars avatar
    79 posts
    Member since:
    Jun 2007

    Posted 24 Sep 2011 Link to this post

    If anyone from support or that knows reads this thread.

    All I really want to know is what .dll files I need to GAC for this to be resolved and if I need any safe control or handler entries in the web.config for everything to work in SharePoint.

  5. Tina Stancheva
    Tina Stancheva avatar
    3298 posts

    Posted 28 Sep 2011 Link to this post

    Hi Dogears,

    When you add the Telerik.Windows.RadUploadHandler.dll in the SharePoint solution you need to make sure that the dll is included into the SharePoint project Package:

    Also, it is better to override the SaveChunkData method in the UploadHandler, rather than the ProsessStream. I attached a sample project demonstrating how you can implement your scenario. Let us know if we can further assist you.

    All the best,
    Tina Stancheva
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top