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:
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:
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:
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
Thanks!
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()
{
base.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);
fs.Close();
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=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ WebHandler Language="C#" Class="FileUploadSP.TestClass, FileUploadSP, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7c8e2c3ef53023ee" %>
And finally my XAML for the control itself:
<
UserControl
x:Class
=
"FileUploadSL.MainPage"
xmlns:telerik
=
"clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Input"
mc:Ignorable
=
"d"
d:DesignHeight
=
"300"
d:DesignWidth
=
"400"
>
<
Grid
x:Name
=
"LayoutRoot"
Background
=
"White"
>
<
telerik:RadUpload
x:Name
=
"RadUpload1"
HorizontalAlignment
=
"Left"
VerticalAlignment
=
"Top"
IsAppendFilesEnabled
=
"True"
IsAutomaticUpload
=
"False"
MaxFileCount
=
"10"
MaxFileSize
=
"100000000"
MaxUploadSize
=
"200000000"
OverwriteExistingFiles
=
"True"
TargetFolder
=
"FileTemp"
BufferSize
=
"512"
UploadServiceUrl
=
"/_layouts/FileUploadSP/UploadHandler.ashx"
/>
</
Grid
>
</
UserControl
>
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
Thanks!