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()
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 type: HttpParseException
Exception message: Exception of type 'System.Web.HttpParseException' was thrown.
Request path: /_layouts/FileUploadSP/UploadHandler.ashx
User host address: fe80::543f:cf7d:803d:6749WSS_Minimal
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=22.214.171.124, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ WebHandler Language="C#" Class="FileUploadSP.TestClass, FileUploadSP, Version=126.96.36.199, Culture=neutral, PublicKeyToken=7c8e2c3ef53023ee" %>
And finally my XAML for the control itself:
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