我想用异步调用,来实现页面跳转:context.Server.Execute("ActualPage2.aspx");注:context为HttpContext对象,为什么老是出错?
代码如下:
public class Handler:IHttpAsyncHandler
{
private delegate void CreateCommand(HttpContext context);
public Handler()
{
}
public void ProcessRequest(HttpContext context)
{
context.Server.Execute("ActualPage2.aspx");
}
public void Execute(IAsyncResult ar)
{
CreateCommand command = (CreateCommand)ar.AsyncState;
if (ar.IsCompleted == false)
{
System.Threading.Thread.Sleep(500);
}
command.EndInvoke(ar);
}
public bool IsReusable
{
get
{
return true;
}
}
public IAsyncResult BeginProcessRequest(HttpContext ctx, AsyncCallback cb, object obj)
{
CreateCommand command = new CreateCommand(ProcessRequest);
IAsyncResult ar = command.BeginInvoke(ctx,cb,command);
if (ar.IsCompleted == false)
{
System.Threading.Thread.Sleep(5000*2);
}
if (ar.IsCompleted)
{
command.EndInvoke(ar);
}
return ar;
}
public void EndProcessRequest(IAsyncResult ar)
{
}
}