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;
}
The corresponding code bind is
[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 };
}
}
When i run this code in .net development server it works fine.But when i host this in IIS server i am getting 500 internal server error.
the only difference i found in local system and IIS is
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
From IIS server
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
The Response header Content_Type is different in both case.Also the content-Length is also different.
http://net30.aaa.net/Cribs.aspx/GetBinOptions?TypeID=0 is sending 5 times if the options has 5 values.If the option has 3 values then the request is sending 3 times. That's how the Content-Length is different in IIS.
Does anybody know the reason behind this.Any help would be greatly appreciated. Thank you
I found that the project is deployed on AZX folder.So for calling the options the URL should be http://net30.aaa.net/AZX/Cribs.aspx/GetBinOptions?TypeID=0 instead of http://net30.aaa.net/Cribs.aspx/GetBinOptions?TypeID=0 .All other link are same(http://net30.aaa.net/AZX/***.aspx) except this one.
I solved the issue by making the options URL the absolute url(http://net30.aaa/AZX/Cribs.aspx/GetBinOptions?TypeID=0)` Instead of hard coding i defined the domain in web.config .
<configuration>
<appSettings>
<add key="domain" value="'http://net30.aaa/AZX'"/> <!-- (add the single quotes) -->
</configuration>
</appSettings>
Read this value in page load and pass it into the options
public partial class Cribs : System.Web.UI.Page
{
public string appdomain;
protected void Page_Load(object sender, EventArgs e)
{
appdomain = ConfigurationManager.AppSettings["domain"].ToString();
}
}
In the 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;
}
}