简体   繁体   English

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

[英]Not working on azure server but works fine in local environment?

I have jQuery Ajax method to call a web method in C# code. 我有jQuery Ajax方法来调用C#代码中的Web方法。 The code works fine in local environment but it does not work in server. 代码在本地环境中工作正常,但在服务器中不起作用。 But some web method and jQuery Ajax calls work fine with normal SQL statement, but with a stored procedure in web method which returns some data it does not work. 但是一些web方法和jQuery Ajax调用在普通的SQL语句中运行良好,但是在web方法中存储过程会返回一些不起作用的数据。 It shows an error message as 它显示错误消息

{Message: "There was an error processing the request.",StackTrace:"", ExceptionType: ""} {消息:“处理请求时出错。”,StackTrace:“”,ExceptionType:“”}
ExceptionType:"" ExceptionType: “”
Message:"There was an error processing the request." 消息:“处理请求时出错。”
StackTrace:"" 堆栈跟踪:””

Here's my Ajax call... 这是我的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'
                        }
                    }
                });

Here's my web method: 这是我的网络方法:

[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;
 }

Is there any extra thing I need to do in server? 我需要在服务器上做什么额外的事情吗?

After 5 hrs of explore i finally found some silly mistake which was in my web.config file 经过5个小时的探索,我终于发现了一些在我的web.config文件中的愚蠢错误

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

works fine....Thank you 工作正常....谢谢

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Twilio SMS 无法通过部署到 Web 服务器的 ASP.NET MVC C# web 工作(但在本地测试环境中工作正常) - Twilio SMS not working via ASP.NET MVC C# web deployed to Web Server (but works fine in local test environment) 更新面板中的按钮不能在INT环境中工作,但在Dev环境中工作正常(两者都在同一服务器中) - Button inside update panel is not working on INT Environment but works fine in Dev environment (both are in the same server) 连接到Azure数据库的Azure网站在本地运行良好,但未部署 - Azure Website Connecting to Azure Database works fine on local but not deployed 为什么我的 Azure API 在本地环境中运行时返回 500 内部服务器错误? - Why is My Azure API returning 500 internal server error when it works in a local environment? Azure Webjob在本地工作正常,但在Azure门户上不工作 - Azure Webjob working fine in local but it's not working on Azure portal Ajax自动完成CSS在iis和服务器上工作正常,但在本地计算机上工作不正常 - Ajax Auto complete Css works fine in iis and the server but not in local machine 在服务器中获取“索引超出数组范围”异常,本地工作正常 - Getting “Index was outside the bounds of the array” exception in server, local works fine 具有Azure AD身份验证的MVC Webapp在本地运行良好,但在移植到Azure应用程序服务时无法正常运行 - MVC webapp with Azure AD authentication works fine in local but not when porting to Azure app services 带有AjaxControlTolKit的aspx页面在服务器中不起作用,但在本地 - aspx page with AjaxControlTolKit not working in server but works with local Calc无法在服务器上运行,但可以在本地服务器上运行 - Calc not working on server , yet works on local
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM