Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6105661
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:59:42+00:00 2026-05-23T13:59:42+00:00

I have recently ran into a problem that would not allow me to use

  • 0

I have recently ran into a problem that would not allow me to use DELETE and PUT requests into my .ashx file, so I added the proper verbs in order to allow that access. Now I am getting a 500 Internal Server Error. Here is my web.config for the handlers:

<handlers>
      <remove name="OPTIONSVerbHandler" />
      <remove name="WebServiceHandlerFactory-Integrated" />
      <remove name="svc-Integrated" />
      <remove name="WebDAV" />
      <add name="svc-Integrated" path="*.svc" verb="*" type="System.ServiceModel.Activation.HttpHandler, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" preCondition="integratedMode" />
      <add name="OwssvrHandler" scriptProcessor="C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\isapi\owssvr.dll" path="/_vti_bin/owssvr.dll" verb="*" modules="IsapiModule" preCondition="integratedMode" />
      <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
      <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
      <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
      <add name="JSONHandlerFactory" path="*.json" verb="*" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" resourceType="Unspecified" preCondition="integratedMode" />
      <add name="ReportViewerWebPart" verb="*" path="Reserved.ReportViewerWebPart.axd" type="Microsoft.ReportingServices.SharePoint.UI.WebParts.WebPartHttpHandler, Microsoft.ReportingServices.SharePoint.UI.WebParts, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />
      <add name="ReportViewerWebControl" verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
    <add name="ashxhandler" path="*.ashx" verb="*" type="System.Web.UI.SimpleHandlerFactory" validate="True" />   
</handlers>

Here is the httpHandlers:

<httpHandlers>
<add path="*.ashx" verb="*" type="System.Web.UI.SimpleHandlerFactory" validate="True" />
    </httpHandlers>

Any ideas? I already went to IIS 7, went to Request Filtering, added .ashx file extension, set it to true and then in the HTTP Verbs section I added DELETE, POST, GET, HEADER, PUT.

EDIT:

Here is my .ashx file:

<%@ WebHandler Language="C#" Class="jQueryUploadTest.Upload" %>

using System;
using System.Collections.Generic;
using System.IO;
using System.Security.AccessControl;
using System.Web;
using System.Web.Script.Serialization;

namespace jQueryUploadTest {

    public class Upload : IHttpHandler {
        public class FilesStatus
        {/*
            public string thumbnail_url { get; set; }
            public string name { get; set; }
            public string url { get; set; }
            public int size { get; set; }
            public string type { get; set; }
            public string delete_url { get; set; }
            public string delete_type { get; set; }
            public string error { get; set; }
            public string progress { get; set; }
           */

            private string m_thumbnail_url;
            private string m_name;
            private string m_url;
            private int m_size;
            private string m_type;
            private string m_delete_url;
            private string m_delete_type;
            private string m_error;
            private string m_progress;

            public string thumbnail_url { get { return m_thumbnail_url; } set { m_thumbnail_url = value; } }
            public string name { get { return m_name; } set { m_name = value; } }
            public string url { get { return m_url; } set { m_url = value; } }
            public int size { get { return m_size; } set { m_size = value; } }
            public string type { get { return m_type; } set { m_type = value; } }
            public string delete_url { get { return m_delete_url; } set { m_delete_url = value; } }
            public string delete_type { get { return m_delete_type; } set { m_delete_type = value; } }
            public string error { get { return m_error; } set { m_error = value; } }
            public string progress { get { return m_progress; } set { m_progress = value; } }
        }
        private readonly JavaScriptSerializer js = new JavaScriptSerializer();
        private string ingestPath;
        public bool IsReusable { get { return false; } }
        public void ProcessRequest (HttpContext context) {
            //var r = context.Response;
            ingestPath = @"C:\temp\ingest\";

            context.Response.AddHeader("Pragma", "no-cache");
            context.Response.AddHeader("Cache-Control", "private, no-cache");

            HandleMethod(context);
        }

        private void HandleMethod (HttpContext context) {
            switch (context.Request.HttpMethod) {
                case "HEAD":
                case "GET":
                    ServeFile(context);
                    break;

                case "POST":
                    UploadFile(context);
                    break;

                case "DELETE":
                    DeleteFile(context);
                    break;

                default:
                    context.Response.ClearHeaders();
                    context.Response.StatusCode = 405;
                    break;
            }
        }

        private void DeleteFile (HttpContext context) {
            string filePath = ingestPath + context.Request["f"];
            if (File.Exists(filePath)) {
                File.Delete(filePath);
            }
        }

        private void UploadFile (HttpContext context) {
            List<FilesStatus> statuses = new List<FilesStatus>();
            System.Collections.Specialized.NameValueCollection headers = context.Request.Headers;

            if (string.IsNullOrEmpty(headers["X-File-Name"])) {
                UploadWholeFile(context, statuses);
            } else {
                UploadPartialFile(headers["X-File-Name"], context, statuses);
            }


            WriteJsonIframeSafe(context, statuses);
        }

        private void UploadPartialFile (string fileName, HttpContext context, List<FilesStatus> statuses) {
            if (context.Request.Files.Count != 1) throw new HttpRequestValidationException("Attempt to upload chunked file containing more than one fragment per request");
            Stream inputStream = context.Request.Files[0].InputStream;
            string fullName = ingestPath + Path.GetFileName(fileName);

            using (FileStream fs = new FileStream(fullName, FileMode.Append, FileAccess.Write)) {
                byte[] buffer = new byte[1024];

                int l = inputStream.Read(buffer, 0, 1024);
                while (l > 0) {
                    fs.Write(buffer,0,l);
                    l = inputStream.Read(buffer, 0, 1024);
                }
                fs.Flush();
                fs.Close();
            }
            FilesStatus MyFileStatus = new FilesStatus();
            MyFileStatus.thumbnail_url = "Thumbnail.ashx?f=" + fileName;
            MyFileStatus.url = "Upload.ashx?f=" + fileName;
            MyFileStatus.name = fileName;
            MyFileStatus.size = (int)(new FileInfo(fullName)).Length;
            MyFileStatus.type = "image/png";
            MyFileStatus.delete_url = "Upload.ashx?f=" + fileName;
            MyFileStatus.delete_type = "DELETE";
            MyFileStatus.progress = "1.0";

          /*  {
                thumbnail_url = "Thumbnail.ashx?f=" + fileName,
                url = "Upload.ashx?f=" + fileName,
                name = fileName,
                size = (int)(new FileInfo(fullName)).Length,
                type = "image/png",
                delete_url = "Upload.ashx?f=" + fileName,
                delete_type = "DELETE",
                progress = "1.0"
            };
            */
            statuses.Add(MyFileStatus);

        }

        private void UploadWholeFile(HttpContext context, List<FilesStatus> statuses) {
            for (int i = 0; i < context.Request.Files.Count; i++) {
                HttpPostedFile file = context.Request.Files[i];
                file.SaveAs(ingestPath + Path.GetFileName(file.FileName));
                string fileName = Path.GetFileName(file.FileName);
                FilesStatus MyFileStatus = new FilesStatus();
                MyFileStatus.thumbnail_url = "Thumbnail.ashx?f=" + fileName;
                MyFileStatus.url = "Upload.ashx?f=" + fileName;
                MyFileStatus.name = fileName;
                MyFileStatus.size = file.ContentLength;
                MyFileStatus.type = "image/png";
                MyFileStatus.delete_url = "Upload.ashx?f=" + fileName;
                MyFileStatus.delete_type = "DELETE";
                MyFileStatus.progress = "1.0";
                statuses.Add(MyFileStatus);
            }
        }

        private void WriteJsonIframeSafe(HttpContext context, List<FilesStatus> statuses) {
            context.Response.AddHeader("Vary", "Accept");
            try {
                if (context.Request["HTTP_ACCEPT"].Contains("application/json")) {
                    context.Response.ContentType = "application/json";
                } else {
                    context.Response.ContentType = "text/plain";
                }
            } catch {
                context.Response.ContentType = "text/plain";
            }

            string jsonObj = js.Serialize(statuses.ToArray());
            context.Response.Write(jsonObj);
        }

        private void ServeFile (HttpContext context) {
            if (string.IsNullOrEmpty(context.Request["f"])) ListCurrentFiles(context);
            else DeliverFile(context);
        }

        private void DeliverFile (HttpContext context) {
            string filePath = ingestPath + context.Request["f"];
            if (File.Exists(filePath)) {
                context.Response.ContentType = "application/octet-stream";
                context.Response.WriteFile(filePath);
                context.Response.AddHeader("Content-Disposition", "attachment, filename=\"" + context.Request["f"] + "\"");
            } else {
                context.Response.StatusCode = 404;
            }
        }

        private void ListCurrentFiles (HttpContext context) {
            List<FilesStatus> files = new List<FilesStatus>();

            string[] names = Directory.GetFiles(@"C:\temp\ingest", "*", SearchOption.TopDirectoryOnly);

            foreach (string name in names) {
                FileInfo f = new FileInfo(name);
                FilesStatus MyFileStatus = new FilesStatus();
                MyFileStatus.thumbnail_url = "Thumbnail.ashx?f=" + f.Name;
                MyFileStatus.url = "Upload.ashx?f=" + f.Name;
                MyFileStatus.name = f.Name;
                MyFileStatus.size = (int)f.Length;
                MyFileStatus.type = "image/png";
                MyFileStatus.delete_url = "Upload.ashx?f=" + f.Name;
                MyFileStatus.delete_type = "DELETE";

                files.Add(MyFileStatus);
                /*files.Add(new FilesStatus
                {
                    thumbnail_url = "Thumbnail.ashx?f=" + f.Name,
                    url = "Upload.ashx?f=" + f.Name,
                    name = f.Name,
                    size = (int)f.Length,
                    type = "image/png",
                    delete_url = "Upload.ashx?f=" + f.Name,
                    delete_type = "DELETE"
                });*/
            }

            context.Response.AddHeader("Content-Disposition", "inline, filename=\"files.json\"");
            string jsonObj = js.Serialize(files.ToArray());
            context.Response.Write(jsonObj);
            context.Response.ContentType = "application/json";
        }
    }
}

The error:

XML Parsing Error: no element found
Location: http://nbcddmsps01:87/_layouts/IrvineCompany.SharePoint.CLM/aspx/Upload.ashx?f=test.txt
Line Number 1, Column 1:

I ONLY got this error AFTER i added verbs to my web.config so I could call DELETE and PUT requests into the httphandler

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T13:59:42+00:00Added an answer on May 23, 2026 at 1:59 pm

    That error normally means that your handler code is throwing an exception that is not being handled by your code. Take a look.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently ran into this problem: Rails 3 link_to (:method => :delete) not working
Here's a problem I ran into recently. I have attributes strings of the form
I ran into a problem recently and found out that this is a bona-fide
I have several times ran into the same problem, and I would like to
Recently I ran into a fun problem with the Microsoft implementation of the CRTL.
Recently, I ran into a problem with my application: the size of the JSON
I have recently ran into this strange issue, I was trying to reference parent
I recently ran into a problem with my app, On most android phones I
I recently ran into a situation where I wanted to use a modeless dialog
I have recently started messing round with CodeIgniter and ran into problems when doing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.