I have a WebMethod which I call through Ajax. The code works perfectly through Visual Studio, however once I release it to IIS7 and login, I receive an Internal Server Error (HTTP status 500).
Using Fiddler I see the following:
Could not load file or assembly 'System.Web.Extensions, Version=4.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
I think I maybe need something in the web.config, but I am not sure.
Here is the code:
AJAX
function GetProgressStatus() {
$.ajax({
type: "POST",
url: paths + '/webmethods.asmx/Gety',
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
processData: false,
traditional: true,
success: function (msg) {
for (var i = 0; i < 13; i++) {
SetValueToBox(msg.d[i], i + 2);
SetNumberColor(i + 2);
}
}
});
WebMethod
[System.Web.Services.WebMethod(BufferResponse = false, EnableSession = true)]
public object Gety()
{
if (HttpContext.Current.Session["LoggedInUserType"].ToString() == GlobalVaribles.UserLogged)
{
var viewUserDashboardCountsValueBussinessLogicLayer = new ViewUserDashboardCountsValueBLL();
var userDashboardValues =
viewUserDashboardCountsValueBussinessLogicLayer.GetUserDashboardCountByUserId(Convert.ToInt64(HttpContext.Current.Session["CompanyID"]));
return userDashboardValues;
}
else
{
var viewConsultantDashboardCountValueBussinessLogicLayer =
new ViewConsultantDashboardCountValueBLL();
var consultantDashboardValues =
viewConsultantDashboardCountValueBussinessLogicLayer.GetConsultantDashboardCountByUserId(Convert.ToInt64(HttpContext.Current.Session["LoggedUserId"]));
return consultantDashboardValues;
}
}
Possible fix:
I removed the area where a problem could be. I now just have to go through my site to see if everything still works fine.
<add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=4.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<httpModules>
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</httpModules>