Jquery IIS 服务器中的 jtable 选项失败

Jquery jtable options fails in IIS server

TypeID: {
                            title: 'Type',
                            width: '30%',
                            inputClass: 'validate[required]',
                            options: <%= DisplayCribOptions() %>
                        },
                        Number: {
                            title: 'Crib No',
                            width: '20%'                            
                        },
                        Name: {
                            title: 'Name',
                            width: '20%',
                            listClass: 'align'
                        },
                        ConfigStacks:{
                            title:  'Configurable Stacks',
                            width: '30%',
                            dependsOn:'TypeID',
                            listClass: 'centerCol',

                            options: function (data)
                            {
                                if (data.source  == 'list')
                                {

                               //return ['0','1','2','3','4','5'] ;
                                   return '/Cribs.aspx/GetBinOptions?TypeID=0';
                                }

                                return '/Cribs.aspx/GetBinOptions?TypeID='+data.dependedValues.TypeID;
         }

对应的代码绑定为

[WebMethod(EnableSession = true)]
     public static object GetBinOptions(int TypeID)
            {
                try
                {
                    int[] configBins = new int[6]; ;

                    if (TypeID == 2)
                        configBins = new int[] { 0, 1, 2, 3 };
                    else if ((TypeID == 3) || (TypeID == 4))
                        configBins = new int[] { 0, 1, 2, 3, 4, 5 };
                    else if (TypeID == 1)
                        configBins = new int[] { 0 };
                    else
                        configBins = new int[] { 0, 1, 2, 3, 4, 5 };
                    return new { Result = "OK", Options = configBins };

                }

                catch (Exception ex)
                {
                    return new { Result = "ERROR", Message = ex.Message };
                }
            }

当我 运行 在 .net 开发服务器中运行此代码时 fine.But 当我在 IIS 服务器中托管此代码时,出现 500 内部服务器错误。

我在本地系统和 IIS 中发现的唯一区别是

Request URL:http://localhost:49196/Cribs.aspx/GetBinOptions?TypeID=3
Request Method:POST
Status Code:200 OK
Response Headers
view source
Cache-Control:private, max-age=0
Connection:Close
Content-Length:45
Content-Type:application/json; charset=utf-8
Date:Fri, 07 Aug 2015 00:36:21 GMT
Server:ASP.NET Development Server/11.0.0.0
X-AspNet-Version:4.0.30319

来自 IIS 服务器

Request URL:http://net30.aaa.net/Cribs.aspx/GetBinOptions?TypeID=0
Request Method:POST
Status Code:500 Internal Server Error
Response Headers
view source
Content-Length:75
Content-Type:text/html
Date:Fri, 07 Aug 2015 00:39:09 GMT
Server:Microsoft-IIS/7.0

两者的响应头 Content_Type 不同 case.Also 内容长度也不同。

http://net30.aaa.net/Cribs.aspx/GetBinOptions?TypeID=0 发送 5 次如果选项有 5 values.If 选项有 3 个值那么请求发送 3 次。这就是 IIS 中 Content-Length 的不同之处。

有谁知道this.Any背后的原因吗?将不胜感激。 谢谢

我发现该项目部署在 AZX folder.So 上,用于调用选项 URL 应该是 http://net30.aaa.net/AZX/Cribs.aspx/GetBinOptions?TypeID=0 而不是 http://net30.aaa.net/Cribs.aspx/GetBinOptions?TypeID=0 。所有其他 link 相同(http://net30.aaa.net/AZX/***.aspx) 除了这个。

我通过将选项 URL 设置为绝对 url(http://net30.aaa/AZX/Cribs.aspx/GetBinOptions?TypeID=0) 解决了这个问题` 我没有硬编码,而是在 web.config 中定义了域。

<configuration>
  <appSettings>
    <add key="domain" value="'http://net30.aaa/AZX'"/> <!-- (add the single quotes) -->

</configuration>
  </appSettings>

在页面加载中读取此值并将其传递到选项中

    public partial class Cribs : System.Web.UI.Page
    {
      public string appdomain;
      protected void Page_Load(object sender, EventArgs e)
      {
     appdomain = ConfigurationManager.AppSettings["domain"].ToString();
      }
    }

在jtable中

     ConfigStacks:{
                                title:  'Configurable Stacks',
                                width: '30%',
                                dependsOn:'TypeID',
                                listClass: 'centerCol',

                                options: function (data)
                                {
                                    if (data.source  == 'list')
                                    {


                                        return <%=appdomain%> +'/Cribs.aspx/GetBinOptions?TypeID=0';
                                    }

                                      return  <%=appdomain%> +'/Cribs.aspx/GetBinOptions?TypeID='+data.dependedValues.TypeID;
                               }
                      }