首页 > 解决方案 > 为什么asp vb从ajax调用函数后面的代码返回404未找到

问题描述

我有一个 aspx 页面,我挣扎了好几个小时试图在输入事件的代码后面(vb)中调用一个函数。它不断返回 404 not found 错误,如下所示:

POST http://localhost:51976/simulations/agios.aspx/getbnqlibelle 404 (Not Found)

我的控制:

<asp:TextBox runat="server" ID="tcodebanque" 
    name="tcodebanque" 
    type="text" 
    class="form-control" 
    placeholder="" 
    style="width: 100px; float: left; margin-right: 5px; border: 1px solid #000; 
           font-size: 12px; padding: 5px; height: 25px; border-radius: 0px;"
    onkeypress="getbnqlibelle(); return false;">
</asp:TextBox>

我的阿贾克斯:

<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">
</asp:ScriptManager>

<script type="text/javascript">

    function getbnqlibelle() {
        $.ajax({
            type: "POST",
            url: "agios.aspx/getbnqlibelle",
            data: "{}",
            dataType: "json",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (msg) {
                alert(msg.d);
            }
        });
    }

</script>

我背后的代码:

<System.Web.Services.WebMethod()> 
Public Shared Function getbnqlibelle() As String
    Return ("done")
End Function

我实际上已经尝试了互联网上的所有东西(每个解决方案),没有一个有效,你能帮我吗?

编辑:

尝试了不同的浏览器:同样的错误

标签: asp.netvb.net

解决方案


尝试更改 ajax 函数中的 URL 以包含“模拟”路径。

网址:“模拟/贴水.aspx/getbnqlibelle”

此外,使用浏览器的开发工具来准确验证请求的网络路径。


推荐阅读