我已将我的Debt : System.Web.UI.Page
(WebForms)类定制为具有类型Consumption
的属性,该属性通过构造函数初始化。
public class Debt : System.Web.UI.Page {
public Consumption Consumption {get;set;}
public Debt(Consumption consumption) => Consumption = consumption;
...
}
我有一个处理程序,它根据一些参数决定是否将请求转移到"债务"页面,或者"添加"页。但是如果我们转移到Debt页面,我想通过构造函数传递一个消费对象,如下所示:
处理程序(* .ashx):
public void ProcessRequest(HtmlContext context) {
Consumption c = [...retrieving the consumption...];
IHttpHandler handler = new Debt(c);
context.Server.Transfer(handler, false);
}
转移发生了,但我收到一个空白页,而不是预期的"债务"页。
我已尝试使用Execute()
,这需要TextWriter
参数,但我无法强制Debt页面的ProcessRequest
方法输出其呈现的HTML content(以便TextWriter
的{{1}}参数可以使用输出)。
我想避免Execute
,因为我想要这两页,"债务"和"添加"只能通过处理程序访问,而不是通过在浏览器中输入它们。