是否可以从处理程序中调用另一个处理程序?我有一个自定义的处理程序,每当一个文件类型被请求时,它就会触发,然后我正在经历一些身份验证过程,需要调用另一个处理程序。
我的问题是我不知道如何从这个处理程序中调用另一个处理程序。
非常感谢
发布于 2015-05-30 03:33:05
下面是调用other handler的一种方法:
public class Handler1 : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
var otherurl = "https://localhost:81/otherhandler.ashx";
// using System.Net;
var req = (HttpWebRequest)HttpWebRequest.Create(otherurl);
var sr = new StreamReader(req.GetResponse().GetResponseStream());
// read stuff: sr.ReadBlock(), sr.ReadToEnd(), ...
// do something with the response
context.Response.Write("Hello World");
}
}https://stackoverflow.com/questions/30537578
复制相似问题