在asp.net Ajax网站中获取错误

时间:2014-02-11 10:17:20

标签: c# jquery asp.net webmethod

我在asp.net AJAX中创建了我的网站。对于AJAX请求,我使用了jquery,它调用静态WebMethod。

它在我的计算机上工作得很好但是当多个用户使用我的网站时我收到错误。

C#代码

    [WebMethod(EnableSession = true)]
    public static string SaveRatingsCollegeReview(string RatingXML)
    {
        UserParam UserParamObj = new UserParam();
        UserParamObj = (UserParam)HttpContext.Current.Session["ReviewDataOfUser"];
        Review ReviewDH = new Review();

        UserParamObj.RatingXML = RatingXML;
        ReviewDH.SaveRatingXML(UserParamObj);

        return "Success";
    }

JS代码:

function SaveRating() {
    //Finding HTML Controls;
    var CurrentSrNoObj = document.getElementById("cb_SrNo");
    var CategoryIdObj = document.getElementById("cb_CategoryId");
    var titleObj = document.getElementById("txtTitle");
    var WhyObj = document.getElementById("txtWhy");
    var GreatObj = document.getElementById("txtGreat");
    var NotGreatObj = document.getElementById("txtNotGreat");
    var Rating = document.getElementById("currentRating0");

    titleObj.focus();

    var ErrorObj = ValidateForm(titleObj,WhyObj,GreatObj,NotGreatObj,Rating);

    if (ErrorObj.IsValid == true) {
        var parameters = JSON.stringify({ 'CategoryId': CategoryIdObj.value, 'SrNo': CurrentSrNoObj.value, 'Title': titleObj.value, 'Why': WhyObj.value, 'Great': GreatObj.value, 'NotGreat': NotGreatObj.value, 'Rating': Rating.value});
        AjaxRequestUsingPost("../AjaxFunctions.aspx/SaveReview3", parameters, SuccessRedirect); // Wrapper function to make ajax call
    }
    else 
    {
        alert(ErrorObj.ErrorMessage);
    }
}

0 个答案:

没有答案