不在azure服务器上工作但在本地环境中工作正常吗?

时间:2016-12-29 09:49:29

标签: c# jquery asp.net ajax azure-web-sites

我有jQuery Ajax方法来调用C#代码中的Web方法。代码在本地环境中工作正常,但在服务器中不起作用。但是一些web方法和jQuery Ajax调用在普通的SQL语句中运行良好,但是在web方法中存储过程会返回一些不起作用的数据。它显示错误消息

  

{消息:“处理请求时出错。”,StackTrace:“”,ExceptionType:“”}
  ExceptionType: “”
  消息:“处理请求时出错。”
  堆栈跟踪: “”

这是我的Ajax电话......

$.ajax({
            url: "AutoRFQ_Vendors_SP.aspx/BindGrid"
            , type: "POST"
            , data: JSON.stringify(objdrpdata)
            , contentType: "application/json;"
            , success: function (data) {
                $body.removeClass("loading");
                var vendorsource = {
                    datatype: "json"
                    , localdata: data.d
                    , datafields: [
                        {
                            name: 'CommonMakerNameDisplay'
                        }
                        , {
                            name: 'EqpExtendType'
                        }
                        , {
                            name: 'CommonMakerName'
                        }
                        , {
                            name: 'IsForAutoRFQ'
                        }
                        , {
                            name: 'VendorName'
                        }
                        , {
                            name: 'CurrencyCode'
                        }
                        , {
                            name: 'Proc_Vendors_AllowedCurrencyID'
                        }
                        , {
                            name: 'SortCode'
                        }
                        , {
                            name: 'xSortCode'
                        }
                        , {
                            name: 'IsTitle'
                        }
                        , {
                            name: 'NoOfRFQs'
                        }
                        , {
                            name: 'NoOfOrders'
                        }
                        , {
                            name: 'TotalPOAmtInUSD'
                        }
                    }
                });

这是我的网络方法:

[WebMethod(EnableSession = true)]
public static string BindGrid(string vslFilter, string yearFilter, string eqpmtFilter) 
{
      DataTable dt = null;

      string gridvendorlist = "";

      try 
      {
           if (HttpContext.Current.Session["P_Hub_AutoRFQVendorDataTable"] == null || (string) HttpContext.Current.Session["P_Hub_AutoRFQVslFilter"] != vslFilter || (string) HttpContext.Current.Session["P_Hub_AutoRFQYearFilter"] != yearFilter || (string) HttpContext.Current.Session["P_Hub_AutoRFQEqpmtFilter"] != eqpmtFilter) 
           {
               string vslFilterType = "", vslFilterValue = "";

               if (vslFilter.Length == 3) 
                   vslFilter = "VSL-" + vslFilter;

               string[] vslType = vslFilter.Trim().Split('-');

               if (vslType[0].ToString().Trim().ToUpper() == "VSL") 
               {
                   vslFilterType = "VSL";
                   vslFilterValue = vslType[1].ToString();
               } 
               else if (vslFilter != "-1") 
               {
                   vslFilterType = "Group";
                   vslFilterValue = vslFilter.ToString();
               }

               string spName = "W_Enh_CommonMakers_RFQVendors";

               string[] paramField = { "@CompanyCode", "@VslFilterType",
                                       "@VslFilterValue", "@NoOfYrToShow",
                                       "@EQ_EquipmentID" };
               object[] paramValue = { GenFuncs.COMPANYCODE,
                                       vslFilterType,
                                       vslFilterValue,
                                       yearFilter,
                                       eqpmtFilter };
               dt = DBFuncs.dbExecuteSP(spName, paramField, paramValue);

               HttpContext.Current.Session["P_Hub_AutoRFQVendorDataTable"] = dt;
               HttpContext.Current.Session["P_Hub_AutoRFQVendorSelectedRowIndex"] = null;
               HttpContext.Current.Session["P_Hub_AutoRFQ_ScrollIndex"] = null;
               HttpContext.Current.Session["P_Hub_AutoRFQVslFilter"] = vslFilter;
               HttpContext.Current.Session["P_Hub_AutoRFQYearFilter"] = yearFilter;
               HttpContext.Current.Session["P_Hub_AutoRFQEqpmtFilter"] = eqpmtFilter;

               gridvendorlist = Func_Ajax.GetJson(dt);
           } 
           else 
           {
               dt = (DataTable)HttpContext.Current.Session["P_Hub_AutoRFQVendorDataTable"];
               gridvendorlist = Func_Ajax.GetJson(dt);
           }
      } 
      catch (Exception err) 
      {
           GenFuncs.AddToErrLog("-1", "xxx", "Error", err.Message, Path.GetFileName(HttpContext.Current.Request.PhysicalPath), "BindGrid");
      } 
      finally 
      {
           dt = null;
      }

      return gridvendorlist;
 }

我需要在服务器上做些额外的事吗?

1 个答案:

答案 0 :(得分:0)

经过5小时的探索后,我终于发现了一些在我的web.config文件中的愚蠢错误

  <system.web.extensions>
        <scripting>
          <webServices>
            <jsonSerialization maxJsonLength="2147483647"/>
          </webServices>
        </scripting>
      </system.web.extensions>

工作正常....谢谢