Web 服务 (.asmx) 在 IIS 7 中抛出 404 错误

Web Service(.asmx) is throwing 404 error in IIS 7

我遇到了一个与 Web 服务调用相关的问题。它在我的本地机器上 运行 非常好。但是一旦我将它部署在网络(IIS 7)服务器上并尝试进行服务调用,那一刻它就会抛出 404(找不到资源)错误。

为您提供的信息,我已将服务保存在网络服务器上的适当位置,我也检查了权限它也可以。 对于您的提示,jsdebug 没有在网络服务器上创建 例如: 如果我将 url 放在我的本地计算机 http://localhost:8080/Service.asmx/jsdebug 中,那么 jsdebug 会附带下载选项,但是当我将其放在 Web 服务器上时,就会出现以下错误:

"404 - 找不到文件或目录。 您要查找的资源可能已被删除、名称已更改或暂时不可用。"

请建议

试试这个:

JS

$.ajax({
        type: "POST",
        url: 'WebService.asmx/YourMethod',
        data: {},
        async: false,
        contentType: "application/json; charset=utf-8",
        success: function (result) { 
              alert(result.d);
        },
        failure: function (error) {
        }
    });

ASMX

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
[System.Web.Script.Services.ScriptService]
[Serializable]
public class WebService : System.Web.Services.WebService
{

            [WebMethod]
            public string YourMethod()
            {
                  return "OK";
            }
}

WebConfig(在 system.web 标签内)

  <webServices>
    <protocols>
      <add name="HttpGet"/>
      <add name="HttpPost"/>
    </protocols>
  </webServices>

此问题已解决。当我们遇到这个问题时,我们正在使用 DNN 7.3 更新我们的应用程序。此场景中的解决方案是从 DNN.

提供的 webconfig 中删除 路由协议

非常感谢您的回复,我很感激。