【发布时间】:2020-01-07 11:33:40
【问题描述】:
我在下面创建了 asmx 文件:
namespace Webhook
{
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
public class WebhookEvent : System.Web.Services.WebService
{
[WebMethod(EnableSession = true)]
[ScriptMethod(UseHttpGet = false, ResponseFormat = ResponseFormat.Json)]
public void ReceiveEvents()
{
string fileName = @"D:\myfile.txt";
try
{
//HttpContext.Current.Response.Write("{property: value}");
// Check if file already exists. If yes, delete it.
if (File.Exists(fileName))
{
File.Delete(fileName);
}
// Create a new file
using (FileStream fs = File.Create(fileName))
{
// Add some text to file
Byte[] title = new UTF8Encoding(true).GetBytes("New Text File \n");
fs.Write(title, 0, title.Length);
/// byte[] author = new UTF8Encoding(true).GetBytes(jsonString);
// fs.Write(author, 0, author.Length);
}
// Open the stream and read it back.
using (StreamReader sr = File.OpenText(fileName))
{
string s = "";
while ((s = sr.ReadLine()) != null)
{
Console.WriteLine(s);
}
}
}
catch (Exception Ex)
{
Console.WriteLine(Ex.ToString());
}
}
}
}
在这个文件中,我在文本文件中写入简单的文本,并在 d 驱动器中写入。
现在另一个应用程序在此文件 (http://myip/Webhook/WebhookEvent.asmx/ReceiveEvents) 上发送数据(通过钩子),详细信息如下:
Content-Type: application/json
User-Agent: weebdly
Accept-Encoding: gzip
X-weebdly-Hook-Id: 123456
Body :
{
"todayoff":"invitee"
}
因此,当另一个应用程序在我的应用程序上发送数据时,它不会调用此方法。
我还在 IIS 中启用了调试模式。所以我可以检查断点,但它不是调用这个方法。
我该如何解决这个问题?
【问题讨论】:
-
您是否收到任何错误消息?
标签: c# asp.net web-services asp.net-web-api