我有通用处理程序,它定义为
public class ExporterHandler<TFactory, TRequest, TResult>
如果我直接称之为
window.open('/url/ExporterHandler.ashx')
当然我收到错误
有没有办法通过js或c#传递通用参数?
目前的实现相当骇人听闻。
protected void Button_Download_Click(object sender, EventArgs e)
{
var type = this.Page.GetType();
while (!type.IsGenericType)
{
type = type.BaseType;
}
var pageArguments = type.GetGenericArguments();
var handlerType = Assembly.GetExecutingAssembly()
.GetTypes()
.Where(x => x.FullName.Contains("ExporterHandler"))
.Single()
.MakeGenericType(pageArguments);
var handler = (IHttpHandler)Activator.CreateInstance(handlerType);
handler.ProcessRequest(this.Context);
}