最近一个项目,使用ajaxPro2 出现了一个怪异的问题,麻烦大侠们赐教了!
ajaxPro2偶尔无法进到后台方法里去,错误率30%。
奇怪的是发布在内网服务器上没有遇到过,发布外网服务器上就会出错。
c#代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections;
using I.USER.Model.User;
using I.USER.Utility;
using I.USER.BLL;
using I.UserService.NewsServiceS;
[AjaxPro.AjaxNamespace("INews_INews")]
public partial class INews_INews : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e) {
AjaxPro.Utility.RegisterTypeForAjax(typeof(INews_INews));
}
/// <summary>
/// 获取新闻列表
/// </summary>
/// <param name="pageNo"></param>
/// <returns></returns>
[AjaxPro.AjaxMethod]
public ArrayList GetNewsList(int pageNo) {
ArrayList pageList = new ArrayList();
PageOfNewsInfoArMg3z3n newsList = null;
string newsPageList = "";
try {
LoginInfo loginInfo = Tools.GetSession("LoginInfo") as LoginInfo;
if (loginInfo != null) {
string[] cityInfo = Tools.GetSession("cityInfo") as string[];
int cityId = -1;
if (cityInfo != null) {
cityId = int.Parse(cityInfo[0]);
}
if (pageNo == 1) {
newsList = CacheTools.GetCache("news" + cityId + "_1") as PageOfNewsInfoArMg3z3n;
if (newsList == null) {
newsList = NewsBLL.GetNewsWithPageInfo(pageNo, cityId);
CacheTools.Insert("news" + cityId + "_1", newsList, 3600);
}
}
else {
newsList = NewsBLL.GetNewsWithPageInfo(pageNo, cityId);
}
if (newsList != null && newsList.InfoList != null) {
if (newsList.InfoList.Length > 0) {
newsPageList = Tools.GetListPageHtml(pageNo, (int)newsList.PageCount, "getNewsList({0})", "newsPageList");
}
}
if (newsList == null) {
LogTools.Error("调用服务返回null,传入参数:" + pageNo + "," + cityId, this.GetType());
}
pageList.Add(newsList);
pageList.Add(newsPageList);
}
}
catch (Exception e) {
pageList = null;
LogTools.Error(e.Message, e, this.GetType());
}
return pageList;
}
}
js代码:
function getNewsList(pageNo) {
var res = INews_INews.GetNewsList(pageNo).value;
var liStr = "";
if (res != null) {
if (res[0] != null && res[0].InfoList != null && res[0].InfoList.length != 0) {
for (var i = 0; i < res[0].InfoList.length; i++) {
liStr += "<li><span class='FL_right'>" + (res[0].InfoList[i].PublisthTime).toString1() + "</span><a href='javascript://' onclick='getNewsDetail(" + res[0].InfoList[i].NewsId + ")'>" + replaceHtml(res[0].InfoList[i].Title) + "</a></li>"
}
}
else {
liStr += "<li class='TA_center' style='border-bottom:none;'>暂无资讯!</li>";
}
$("#newsList").html(liStr);
$("#newsPageList").remove();
$("#newsList").after(res[1]);
}
else {
liStr += "<li class='TA_center' style='border-bottom:none;'>系统异常</li>";
$("#newsList").html(liStr);
}
}
webconfig配置:
<httpHandlers>
<add verb="POST,GET" path="ajaxpro/*.ashx" type="AjaxPro.AjaxHandlerFactory, AjaxPro.2"/>
</httpHandlers>
头痛了,找了很久都不知道啥原因。
问题解决了吗,我也遇到这个问题
用jquery的ajax替代了
我在VS2012里面做的时候也是遇到js里面无法调用后台的函数,说页面类没定义,有解决方法么?
用jquery的ajax替代了
@selina_sln: 有例子吗? 怎么整啊
webconfig配置:
<httpHandlers> <add verb="POST,GET" path="ajaxpro/*.ashx" type="AjaxPro.AjaxHandlerFactory, AjaxPro.2"/> </httpHandlers>
改为
<httpHandlers> <add name="ajaxpro/*.ashx_GET,HEAD,POST,DEBUG" path="ajaxpro/*.ashx" verb="GET,HEAD,POST,DEBUG" type="AjaxPro.AjaxHandlerFactory,AjaxPro.2" preCondition="integratedMode,runtimeVersionv2.0" /> </httpHandlers>
或者是这个,不同服务器上面多实验试试。
<httpHandlers> <add name="ajaxpro/*.ashx_GET,HEAD,POST,DEBUG" path="ajaxpro/*.ashx" verb="GET,HEAD,POST,DEBUG" type="AjaxPro.AjaxHandlerFactory,AjaxPro.2" /> </httpHandlers>
马克