Moving an AJAX call from IIS6 to IIS7.5 fails with System.Web.Handlers.ScriptModule.OnPostAcquireRequestState

I am making an AJAX call for WebMethod in IIS6 on Win2003Srv, like this, and it works fine:

<System.Web.Services.WebMethod()> _ Public Shared Sub EmailManagers() 'code End Sub 

with an AJAX call as follows:

  function EmailManagers_Click() { alert('staring email send'); $.ajax({ type: "POST", //url: "EACApprovalOverview.aspx/EmailManagers(" + document.URL + ")", url: "EACApprovalOverview.aspx/EmailManagers", data: "{}", contentType: "application/json; charset=utf-8", dataType: "json", success: function (msg) { alert("Emails Sent!"); }, fail: function (msg) { alert("Email Send Failed!"); } }); alert('end email send'); return false; }; 

When I run this application under IIS7.5 on Win2008Srv, I get "Object reference not installed in object instance". Here's the stack trace:

 [NullReferenceException: Object reference not set to an instance of an object.] System.Web.Handlers.ScriptModule.OnPostAcquireRequestState(Object sender, EventArgs eventArgs) +162 System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +68 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75 

Other errors that I see in the postings contain an extra line at the top of the stack trace, for example:

  at System.Web.Script.Services.WebServiceData.GetMethodData(String methodName) at System.Web.Handlers.ScriptModule.OnPostAcquireRequestState(Object sender, EventArgs eventArgs) at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) 

Since I am not getting to the call to WebServiceData.GetMethodData, I assume that System.Web.Handlers does not load correctly, causing the ScriptModule to be null.

I have this in my web.config:

 <httpModules> <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> </httpModules> 

and I made sure .net 3.5 sp1 is installed. I even checked the GAC and there is a dll there. What am I missing?

+4
source share
1 answer

After introducing the new page method in the new aspx, a NullReferenceException exception occurred in the HerePostAcquireRequestState event as well. This happened only on live servers, but not on the development server.

The problem was that the live server was updated by copying only the bin directory from the precompiled web deployment project. Since the site was precompiled with a wildcard handler as well, aspx performed just fine without the physical presence of aspx.

But calling page methods requires aspx to be present, so the page method works again after just copying the aspx precompiled placeholder to a live server.

+1
source

Source: https://habr.com/ru/post/1483632/


All Articles