Error calling generic handlers (ashx) c # with JavaScript getXMLObject

1

I have a generic handlers that I plan to use to check the database connection from my website, it is called by a JS file which uses > XMLHttpRequest to make the request to the server IIS local and return an object that will be shown in the ASPX, however when making the request the browser receives a request response 404 strong> and looking for the url with the getXMLObject () object; just throw status http 302 found

This is my handler:

public class folderAccess : IHttpHandler
{

    public void ProcessRequest(HttpContext context)
    {
        ManageForm(context);
    }

    public void ManageForm(HttpContext context)
    {
        context.Response.Write("<html><body><form>");

        context.Response.Write("<h2>Hello there. What's cool about .NET?</h2>");
        context.Response.Write("<select name='Feature'>");
        context.Response.Write("<option> Strong typing</option>");
        context.Response.Write("<option> Managed code</option>");
        context.Response.Write("<option> Language agnosticism</option>");
        context.Response.Write("<option> Better security model</option>");
        context.Response.Write("<option> Threading and async delegates</option>");
        context.Response.Write("<option> XCOPY deployment</option>");
        context.Response.Write("<option> Reasonable HTTP handling framework</option>");
        context.Response.Write("</select>");
        context.Response.Write("</br>");
        context.Response.Write("<input type=submit name='Lookup' value='Lookup'></input>");
        context.Response.Write("</br>");

        context.Response.Write("</form></body></html>");
    }

    public bool IsReusable
    {
        get
        {
            return false;
        }
    }
}

this is the javascript that calls it

function callAjaxPost(url, params, callBack) {
var xmlhttp = new getXMLObject();
xmlhttp.open("POST", url, true);
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp.setRequestHeader("Content-length", params.length);
xmlhttp.setRequestHeader("Connection", "close");
xmlhttp.onreadystatechange = function () {//Call a function when the state changes.
    if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
        callBackAjax(xmlhttp, null, callBack);
    }
}
xmlhttp.send(params);

}

this is the function that is in the ASPX that calls the JS file

function browseAccess(path) {
    var sid = document.getElementById("sessionid").value;
    var div = document.getElementById("divPermisos");
    wait();
    callAjaxPost("(S(" + sid + "))/testProyect/folderAccess.ashx", "path=" + path + "&domain=" + _$("SET.domain").value, listFolder);
}

function listFolder(val) {
    val = "<div style='width:680px;height:350px;overflow:auto'>" + val + "</div>";
    showMsg(val, "<%=M0074%>", 700, true);
}

browser response

    
asked by afrejhu 29.07.2017 в 05:12
source

0 answers