如何解决错误HTTP 404.15

时间:2018-07-05 22:57:53

标签: asp.net ajax asp.net-mvc json.net asp.net-ajax

我的问题是,当我尝试在ajax中进行请求时,此刻发送信息时出现此错误:

“请求过滤”模块配置为在查询字符串过长时拒绝请求。

我看到了问题,这是我通过GET请求发送的大量信息。有人有解决此问题的解决方案吗?

在这里,我从ajax和我使用的控制器中留下一个示例

$.ajax({
        type: "GET",
        url: "@Url.Action("nuevaTarjetaCapacitacion", "TarjetaCapacitacion")",
        scriptCharset: "iso-8859-1",
        dataType: "json",
        contentType: "application/json; charset=iso-8859-1",
        data: {
            TarjetaCapacitacionId: $("#TarjetaCapacitacionId").val(),
            NombreCurso: $("#NombreCurso").val(),
            Descripcion: $("#Descripcion").val(),
            FechaInicio: $("#FechaInicio").val(),
            FechaFin: $("#FechaFin").val(),
            //TipoCurso: $("#TipoCurso").val(),
            Departamentos: tarjetaCapacitacion.Departamentos.toString(),
            Puestos: tarjetaCapacitacion.Puestos.toString(),
            Personal: tarjetaCapacitacion.Personal.toString(),
            Instructores: tarjetaCapacitacion.Instructores.toString(),
            InstructoresExternos: JSON.stringify(tarjetaCapacitacion.InstructoresExternos),
            Documentos: tarjetaCapacitacion.Documentos.toString(),
            AprobacionId: $("#AprobacionId").val()
        }


public JsonObject nuevaTarjetaCapacitacion(string NombreCurso, string Descripcion, string FechaInicio, string FechaFin, /*string TipoCurso,*/ string Departamentos, string Puestos, string Personal, string Instructores, string InstructoresExternos, string Documentos, int? AprobacionId)
    {
    }

3 个答案:

答案 0 :(得分:0)

您可以使用POST而不是GET。 这样,数据将在HTTP请求的请求正文中,而不在查询字符串中。

答案 1 :(得分:0)

在这里检查:https://forums.asp.net/t/2024846.aspx?HTTP+Error+404+15+query+url+too+long

请求过滤模块配置为在查询字符串过长的情况下拒绝请求。 查看请求的URL,我会看到:

http://localhost:51358/Account/Login?ReturnUrl=%2FAccount%2FLogin%3FReturnUrl%3D%252FAccount%252FLogin%253FReturnUrl%253D%25252FAccount%25252FLogin%25253FReturnUrl%25253D%2525252FAccount%2525252FLogin%2525253FReturnUrl%2525253D%252525252FAccount%252525252FLogin%252525253FReturnUrl%252525253D%25252525252FAccount%25252525252FLogin%25252525253FReturnUrl%25252525253D%2525252525252FAccount%2525252525252FLogin%2525252525253FReturnUrl%2525252525253D%252525252525252FAccount%252525252525252FLogin%252525252525253FReturnUrl%252525252525253D%25252525252525252FAccount%25252525252525252FLogin%25252525252525253FReturnUrl%25252525252525253D%2525252525252525252FAccount%2525252525252525252FLogin%2525252525252525253FReturnUrl%2525252525252525253D%252525252525252525252FAccount%252525252525252525252FLogin%252525252525252525253FReturnUrl%252525252525252525253D%25252525252525252525252FAccount%25252525252525252525252FLogin%25252525252525252525253FReturnUrl%25252525252525252525253D%2525252525252525252525252FAccount%2525252525252525252525252FLogin%2525252525252525252525253FReturnUrl%2525252525252525252525253D%252525252525252525252525252FAccount%252525252525252525252525252FLogin%252525252525252525252525253FReturnUrl%252525252525252525252525253D%25252525252525252525252525252FAccount%25252525252525252525252525252FLogin%25252525252525252525252525253FReturnUrl%25252525252525252525252525253D%2525252525252525252525252525252FAccount%2525252525252525252525252525252FLogin%2525252525252525252525252525253FReturnUrl%2525252525252525252525252525253D%252525252525252525252525252525252FAccount%252525252525252525252525252525252FLogin%252525252525252525252525252525253FReturnUrl%252525252525252525252525252525253D%25252525252525252525252525252525252FAccount%25252525252525252525252525252525252FLogin%25252525252525252525252525252525253FReturnUrl%25252525252525252525252525252525253D%2525252525252525252525252525252525252FAccount%2525252525252525252525252525252525252FLogin%2525252525252525252525252525252525253FReturnUrl%2525252525252525252525252525252525253D%252525252525252525252525252525252525252FAccount%252525252525252525252525252525252525252FLogin%252525252525252525252525252525252525253FReturnUrl%252525252525252525252525252525252525253D%25252525252525252525252525252525252525252F

似乎是某个地方的重定向循环。我怀疑IIS Express配置中有某些内容,但我不知道它可能是什么(基本上是

答案 2 :(得分:0)

$.ajax({
            type: "GET",
            url: "@Url.Action("nuevaTarjetaCapacitacion", "TarjetaCapacitacion")",
            scriptCharset: "iso-8859-1",
            dataType: "json",
            contentType: "application/json; charset=iso-8859-1",
            data: {
                TarjetaCapacitacionId: $("#TarjetaCapacitacionId").val(),
                NombreCurso: $("#NombreCurso").val(),
                Descripcion: $("#Descripcion").val(),
                FechaInicio: $("#FechaInicio").val(),
                FechaFin: $("#FechaFin").val(),
                //TipoCurso: $("#TipoCurso").val(),
                Departamentos: tarjetaCapacitacion.Departamentos.toString(),
                Puestos: tarjetaCapacitacion.Puestos.toString(),
                Personal: tarjetaCapacitacion.Personal.toString(),
                Instructores: tarjetaCapacitacion.Instructores.toString(),
                InstructoresExternos: JSON.stringify(tarjetaCapacitacion.InstructoresExternos),
                Documentos: tarjetaCapacitacion.Documentos.toString(),
                AprobacionId: $("#AprobacionId").val()
                   }
               });

 public JsonResult nuevaTarjetaCapacitacion(string NombreCurso, string Descripcion, string FechaInicio, string FechaFin, /*string TipoCurso,*/ string Departamentos, string Puestos, string Personal, string Instructores, string InstructoresExternos, string Documentos, int? AprobacionId)
        {
            Json("", JsonRequestBehavior.AllowGet)
        }

您应该使用return Json("", JsonRequestBehavior.AllowGet)而不是return Json(""),否则将收到错误消息“此请求已被阻止,因为当在GET请求中使用敏感信息时,敏感信息可能会泄露给第三方网站。允许GET请求,请将JsonRequestBehavior设置为AllowGet。”