我创建了 .ashx 和 .ashx.cs
.ashx 中
<%@ WebHandler language="C#" Class="HandlerExample.TextBuilder" codebehind="TextBuilder.ashx.cs"%>
.ashx.cs 中
using System.Web;
namespace HandlerExample
{
public class MyHttpHandler : IHttpHandler
{
// Override the ProcessRequest method.
public void ProcessRequest(HttpContext context)
{
context.Response.Write("<H1>This is an HttpHandler Test.</H1>");
context.Response.Write("<p>Your Browser:</p>");
context.Response.Write("Type: " + context.Request.Browser.Type + "<br>");
context.Response.Write("Version: " + context.Request.Browser.Version);
}
// Override the IsReusable property.
public bool IsReusable
{
get { return true; }
}
}
复制错了-_- 那里应该是 public class TextBuilder : IHttpHandler
问题依旧```
我想codebehind类,写成
<%@ WebHandler language="C#" Class="TextBuilder"%> 这个不是目的~ 不过还是谢谢您的回答