首页 新闻 会员 周边 捐助

ajaxPro.2.dll 无法调用后台方法

0
悬赏园豆:50 [待解决问题]

最近一个项目,使用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>

 

头痛了,找了很久都不知道啥原因。

selina_sln的主页 selina_sln | 初学一级 | 园豆:150
提问于:2011-12-02 17:52
< >
分享
所有回答(4)
0

问题解决了吗,我也遇到这个问题

fax125 | 园豆:202 (菜鸟二级) | 2012-10-23 15:52

用jquery的ajax替代了

支持(0) 反对(0) selina_sln | 园豆:150 (初学一级) | 2013-05-20 17:01
0

我在VS2012里面做的时候也是遇到js里面无法调用后台的函数,说页面类没定义,有解决方法么?

波仔Robert | 园豆:165 (初学一级) | 2013-05-05 22:41

用jquery的ajax替代了

支持(0) 反对(0) selina_sln | 园豆:150 (初学一级) | 2013-05-20 17:01

@selina_sln: 有例子吗? 怎么整啊

支持(0) 反对(0) 波仔Robert | 园豆:165 (初学一级) | 2013-05-21 23:13
0

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>
Jacob·雅各布 | 园豆:200 (初学一级) | 2013-09-04 14:03

或者是这个,不同服务器上面多实验试试。

<httpHandlers> 

<add name="ajaxpro/*.ashx_GET,HEAD,POST,DEBUG" path="ajaxpro/*.ashx" verb="GET,HEAD,POST,DEBUG" type="AjaxPro.AjaxHandlerFactory,AjaxPro.2"  />

</httpHandlers>
支持(0) 反对(0) Jacob·雅各布 | 园豆:200 (初学一级) | 2013-09-04 15:23
0

马克

赏音师 | 园豆:221 (菜鸟二级) | 2016-05-11 08:51
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册