1

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>
Christian Strempfer
  • 7,291
  • 6
  • 50
  • 75
Donald Jansen
  • 1,937
  • 4
  • 22
  • 41

1 Answers1

0

It seems to me like some of your resources are not available so they should be placed as emmbeded resource. Right click on file -> Properties -> Build Action -> Emmbeded Resource before you build your solution

and remove static if your web method is Static!

Lucky Lefty
  • 347
  • 1
  • 8
  • try web config changes from http://stackoverflow.com/questions/8489707/asp-net-calling-webmethods-inside-an-webservice-internal-server-error?rq=1 – Lucky Lefty Dec 13 '13 at 10:24