我在项目中使用ASP.NET WebService(asmx)
。
请检查我的代码:
[ScriptService]
public class Generic : System.Web.Services.WebService
{
....
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json,UseHttpGet =false)]
public void chatapi()
{
System.IO.File.WriteAllText(Server.MapPath("~") + @"\TextLog\sample.txt", "Hello");
}
....
}
一个非常简单的代码,执行该代码将在该目录中创建sample.txt
。
我已将该方法设置为webHook
,因此将在触发请求时执行该方法。
虽然我在日志中收到如下错误:
我尝试过的事情:
在web.config
<modules runAllManagedModulesForAllRequests="true"/>
<validation validateIntegratedModeConfiguration="false" />
但是没有运气。
尽管当我从postman
显式调用此方法时,它可以工作,但在发生(webhook)事件的情况下,它将生成一个403
日志。
我已将网址设置为遵循http://domain.abc.xy/generic.asmx/chatapi
。
该如何解决?我在哪里做错了?任何帮助或建议将不胜感激!