我不确定在哪里调用或使用处理程序。这是我到目前为止所拥有的......
默认.aspx
<%@Page Inherits="WebApplication1._Default"%>
<%@OutputCache Duration="10" Location="Server" varybyparam="none"%>
<script language="C#" runat="server">
void Page_Init(object sender, EventArgs args) {
}
}
</script>
<html>
<body>
</body>
</html>
默认.aspx.cs
namespace WebApplication1
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
HttpContext contex = Context;
MyHandler temp = new MyHandler();
temp.ProcessRequest(context);
}
}
public class MyHandler : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
var stream = context.Request.InputStream;
byte[] buffer = new byte[stream.Length];
stream.Read(buffer, 0, buffer.Length);
string xml = Encoding.UTF8.GetString(buffer);
... do something with the XML
// We only set the HTTP status code to 202 indicating to the
// client that the request has been accepted for processing
// but we leave an empty response body
context.Response.StatusCode = 202;
}
public bool IsReusable
{
get
{
return false;
}
}
}
}