我正在使用genric处理程序。它返回了Ienumerable类型数据但是当我从Handler得到响应时我无法得到。当我要对该数据执行任何操作时,它会出错。我想我没有以适当的方式回应。任何形式的帮助将不胜感激。
这是我的处理程序。
public class Handler1 : IHttpHandler
{
IUserInfosRepository _userRepo;
public Handler1()
{
this._userRepo = new UserInfosRepository();
}
public void ProcessRequest(HttpContext context)
{
var Suppliers = GetData(Convert.ToInt32(context.Request.QueryString["Active"].ToString()), Convert.ToInt32(context.Request.QueryString["Inactive"].ToString()));
//string name = context.Request.QueryString["name"];
context.Response.Write(Suppliers);
}
public bool IsReusable
{
get
{
return false;
}
}
public IEnumerable<UserInfoModel> GetData(int Active , int InactiveStatus)
{
var objUI = _userRepo.GetAllMembersWithDelete(Active, Active);
return objUI;
}
}
这是我的控制器,因为我正在使用MVC
string HandlerUrl = "http://localhost:8897/Handler1.ashx?Active=" + Status.Active + "&Inactive=" + Status.Inactive + "";
var response = (new WebClient()).DownloadString(HandlerUrl);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://localhost:8897/Handler1.ashx?Active=" + Status.Active + "&Inactive=" + Status.Inactive + "");
HttpWebResponse response1 = (HttpWebResponse)request.GetResponse();
var SearchDate = response.Where(x => x.LastLogin != null).GroupBy(x => x.LastLogin.Value.Date).OrderByDescending(x => x.Key).Select(x => new { LastLogin = string.Format("{0:MM/dd/yyyy}", x.Key) }).ToList();