Home > Net >  ASP.NET callback page how to write? Receiving voice notification of results, it is not written, plea
ASP.NET callback page how to write? Receiving voice notification of results, it is not written, plea

Time:09-22

I development experience is insufficient, inform interface program to invoke the voice, the server will send the results through the callback URL address to me, how I want to receive the results? My idea is to write a ashx page to receive the server notification of results, but still have no idea how to write code, please great god guide, or reference to a case,
Below is the server push notification of results request:


Ashx file code is as follows (think of first receives the request, print to save text, has deployed to the cloud server, test request prompt a 500 error, depressed... ) :

Using Newtonsoft. Json;
Using Newtonsoft. Json. Linq;
using System;
using System.Collections.Generic;
Using System. Collections. Specialized;
using System.IO;
Using System. Linq;
using System.Text;
Using System. The Web;

The namespace Voice_Report
{
///& lt; summary>
///Handler summary description
///& lt;/summary>
Public class Handler: IHttpHandler
{

Public void the ProcessRequest (HttpContext context)
{
NameValueCollection myHeader=new NameValueCollection ();
int i;
String strKey;
The string result;
MyHeader=context. Request. Headers;

Int total=myHeader. Count;
String strResult="";
//get the value of the parameter in the header
For (I=1; i {
StrKey=myHeader. GetKey (I);
If (strKey=="number")
{
StrResult +=myHeader. Get (strKey);
}
If (strKey=="state")
{
StrResult +=myHeader. Get (strKey) + "\ r \ n";
}
}
//get request body value
The Stream resStream=HttpContext. Current.. Request InputStream;
StreamReader sr=new StreamReader (resStream, System. Text. The Encoding. The Default).
String requestXml=sr. ReadToEnd ();
Result=strResult;
//write TXT file
String FullFileName=@ "D: \ log_20200115 TXT";
StreamWriter sw=new StreamWriter (FullFileName, true, Encoding. The Default).
Sw. Write (" test ");
//sw. Write (result. The ToString ());
Sw. Write (" \ r \ n "+" Write complete ");
Sw. The Close ();
}

Public bool IsReusable
{
The get
{
return false;
}
}
}
}
  • Related