locked
ajaxfileupload web.config error RRS feed

  • Question

  • User432705101 posted

    I'm using the latest ajaxcontrolltolkit (7.1005 Sept 2013). I understand that to get the fileupload to work correctly, the below information needs to be added to the <system.web> section of the Web.Config file. (IIS 6)

    <httpHandlers>

    <add verb="*" path="AjaxFileUploadHandler.axd" type="AjaxControlToolkit.AjaxFileUploadHandler, AjaxControlToolkit"/>

    </httpHandlers>

    but after I save this, my entire site breaks and the error displayed is:

    500 - Internal server error.

    There is a problem with the resource you are looking for, and it cannot be displayed.

    Any help is appreaciated.


    Friday, October 25, 2013 11:13 AM

Answers

  • User432705101 posted

    Just realized I'm using IIS 7, which means I had to change the web.config. Now I'm no longer getting the error.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, October 30, 2013 7:24 AM

All replies

  • User-1025250470 posted

    Is you upload control working without changing Web.config? 

    Thank You

    Friday, October 25, 2013 12:47 PM
  • User432705101 posted

    No, It just displays "error"

    Friday, October 25, 2013 12:53 PM
  • User-1025250470 posted

    How you added Ajax File upload? please copy your code also.

    Thank you

    Friday, October 25, 2013 12:57 PM
  • User432705101 posted

    Actually both the file upload and the imageupload portion of the htmleditorextender are affected. I'm working on the htmlextendor now. The image gets saved to the db and the code worked fine in the previous ajax version. Here is the code.

    <asp:TextBox runat="server" ID="txtPosting" TextMode="MultiLine" Columns="85" Rows="17" />

    <ajaxToolkit:HtmlEditorExtender ID="HtmlEditorExtender1" runat="server" EnableSanitization="False" TargetControlID="txtPosting" DisplaySourceTab="True">

    <Toolbar>

    <ajaxToolkit:Undo />

    <ajaxToolkit:Redo /> I took out all the additional buttons to shorten the code.

    <ajaxToolkit:InsertImage />

    </Toolbar>

    </ajaxToolkit:HtmlEditorExtender>

    Protected Sub HtmlEditorExtender1_ImageUploadComplete(sender As Object, e As AjaxControlToolkit.AjaxFileUploadEventArgs) Handles HtmlEditorExtender1.ImageUploadComplete

    Dim ndc As New NewsDataContext

    Dim byt As Byte()

    byt = e.GetContents

    Dim bmp As New Bitmap(New System.IO.MemoryStream(byt))

    Dim ext As String = Path.GetExtension(e.FileName).ToLower

    Dim bitmap As New Bitmap(bmp, newWidth, newHeight)

    Dim stream As System.IO.MemoryStream = New MemoryStream()

    If ext = ".png" Then

    bitmap.Save(stream, System.Drawing.Imaging.ImageFormat.Png)

    ElseIf ext = ".gif" Then

    bitmap.Save(stream, System.Drawing.Imaging.ImageFormat.Gif)

    Else

    bitmap.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg)

    End If

    stream.Position = 0

    Dim image As Byte() = New Byte(stream.Length) {}

    stream.Read(image, 0, image.Length)

    'Save to DB

    Dim imgid As Integer

    Dim att As New attachment

    att.attachmentname = e.FileName

    att.attachment = image

    ndc.attachments.InsertOnSubmit(att)

    ndc.SubmitChanges()

    e.PostedUrl = "getimage.ashx?imageid=" & imgid

    e.DeleteTemporaryData()

    End Sub



    Friday, October 25, 2013 1:05 PM
  • User555306248 posted

    Hi,

    Make sure you install the correct version of the AjaxControlToolkit:

    Version 3.0.20229 2008-02-29 release of the AJAX Control Toolkit targets the official release of .NET Framework 3.5 and Visual Studio 2008.

    Version 1.0.20229 You can also download the Toolkit for .NET Framework 2.0, ASP.NET AJAX 1.0 and Visual Studio 2005.

    Version 3.0.40412

    April 12, 2010 release of the AJAX Control Toolkit for ASP.NET 3.5 Service Pack 1 and Visual Studio 2008 SP1.

    Version 4.1.51116.0

    Nov 16 2011 release of the AJAX Control Toolkit for ASP.NET 4.0 and Visual Studio 2010

    Version 4.1.60919

    September 2012 release of the AJAX Control Toolkit for ASP.NET 4.5 and Visual Studio 2012

    Then you could add the Ajax Control Toolkit to the VS Toolbox step by step at:http://www.asp.net/ajaxlibrary/act.ashx

    Sunday, October 27, 2013 11:46 PM
  • User432705101 posted

    Thanks, but as stated in the original post, I'm using the lates toolkit. This was installed through Nuget, targeting .Net 4.5 and I've updated the toolbox.

    Monday, October 28, 2013 7:59 AM
  • User432705101 posted

    Just realized I'm using IIS 7, which means I had to change the web.config. Now I'm no longer getting the error.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, October 30, 2013 7:24 AM