StackOverflowException when sending JSon data to the server (HTTP / HTTPS)

I have an MVC website that works locally just fine. When I debug the application, of course, it works under the HTTP protocol, then everything works fine.

I have a controller:

[Route("messages/new/form/invoice"), HttpPost] public ActionResult Invoice(object model) { var result = JsonConvert.DeserializeObject<dynamic>(model.ToString()); // Further processing goes here... } 

Note. I removed the code from this method because it is illogical.

This method is called through the AngularJS $ HTTP messaging service. This is done as follows:

 this.saveInvoice = function () { // Post the form. $http({ method: "POST", url: "/messages/new/form/invoice", data: { model: JSON.stringify(this.invoice) }, headers: { 'Content-Type': 'application/json' } }).success(function (data) { $('#content').html(data); }).error(function (error) { console.log('An error occured while saving the form: ' + error); }); } 

This function is called through my view:

 <form id="invoiceForm" name="invoiceForm" ng-submit="invoiceForm.$valid && invoiceCtrl.saveInvoice();" novalidate ng-init="invoiceCtrl.Init(@Model.FlowId)"> 

But, as mentioned earlier, when working on my local computer, the code works fine.

But now I am deploying it to a server where the site runs under the HTTPS protocol , which is different from HTTP on my local machine.

When I execute the code and I click the button to submit the form on the web server, a new window will open and that "Visual Studio Just In Time Debugger" will ask the Visual Studio instance to debug it, but Visual Studio is not installed on this server, which means That I do not need to choose a debugger.

This window is shown to me 3 times. After undoing all these debugger issues in my web browser, I see the following in the console:

 An error occured while saving the form: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd"> <HTML><HEAD><TITLE>Service Unavailable</TITLE> <META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"> </HEAD> <BODY><h2>Service Unavailable</h2> <hr><p>HTTP Error 503. The service is unavailable.</p> </BODY></HTML> 

This means that the application pool has crashed.

So now I have tried the following:

  • Deploying the DEBUG assembly on the server.
  • In web.config, I changed the compilation debugging to false.
  • Installed Visual Studio remote debugger and remote application debugging.

When I remove the remote debugging of the application (which means that I am attached to the remote IIS process), I set a breakpoint on the first line of the method in post action (see my controller above). But this method did not fall at all; instead, remote debugging throws a StackOverflowException as soon as I click the button to submit the form.

I hope that someone can point me in the right direction, because I am lost, and this makes me download for the server clock.

Edit: added web.config

 <?xml version="1.0" encoding="utf-8"?> <configuration> <configSections> <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> <section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging" /> <sectionGroup name="elmah"> <section name="security" requirePermission="false" type="Elmah.SecuritySectionHandler, Elmah" /> <section name="errorLog" requirePermission="false" type="Elmah.ErrorLogSectionHandler, Elmah" /> <section name="errorMail" requirePermission="false" type="Elmah.ErrorMailSectionHandler, Elmah" /> <section name="errorFilter" requirePermission="false" type="Elmah.ErrorFilterSectionHandler, Elmah" /> </sectionGroup> <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --></configSections> <connectionStrings> <!-- Removed for security reasons. --> </connectionStrings> <appSettings> <add key="webpages:Version" value="3.0.0.0" /> <add key="webpages:Enabled" value="false" /> <add key="owin:AutomaticAppStartup" value="false" /> <add key="ClientValidationEnabled" value="true" /> <add key="UnobtrusiveJavaScriptEnabled" value="true" /> <add key="elmah.mvc.disableHandler" value="false" /> <add key="elmah.mvc.disableHandleErrorFilter" value="true" /> <add key="elmah.mvc.requiresAuthentication" value="false" /> <add key="elmah.mvc.IgnoreDefaultRoute" value="false" /> <add key="elmah.mvc.allowedRoles" value="*" /> <add key="elmah.mvc.allowedUsers" value="*" /> <add key="elmah.mvc.route" value="elmah" /> </appSettings> <location inheritInChildApplications="false"> <system.web> <globalization uiCulture="auto" culture="auto" /> <authentication mode="Forms"> <forms loginUrl="~/login" timeout="2880" /> </authentication> <pages> <namespaces> <add namespace="System.Web.Helpers" /> <add namespace="System.Web.Mvc" /> <add namespace="System.Web.Mvc.Ajax" /> <add namespace="System.Web.Mvc.Html" /> <add namespace="System.Web.Optimization" /> <add namespace="System.Web.Routing" /> <add namespace="System.Web.WebPages" /> <add namespace="DocTrails3.Net.ViewModels" /> </namespaces> </pages> <compilation debug="true" targetFramework="4.5.1" /> <httpRuntime targetFramework="4.5.1" requestPathInvalidCharacters="&lt;,&gt;,%,&amp;,:,\,?" relaxedUrlToFileSystemMapping="true" maxRequestLength="1048576" /> <httpModules> <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" /> <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" /> <add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" /> </httpModules> </system.web> <system.webServer> <validation validateIntegratedModeConfiguration="false" /> <security> <requestFiltering> <requestLimits maxAllowedContentLength="1073741824" /> </requestFiltering> </security> <httpProtocol> <customHeaders> <remove name="X-Powered-By" /> </customHeaders> <redirectHeaders> <clear /> </redirectHeaders> </httpProtocol> <modules> <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" preCondition="managedHandler" /> <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" preCondition="managedHandler" /> <add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" preCondition="managedHandler" /> </modules> </system.webServer> </location> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" /> <bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" /> <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" /> <bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" /> <bindingRedirect oldVersion="0.0.0.0-5.1.0.0" newVersion="5.1.0.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Web.Razor" publicKeyToken="31bf3856ad364e35" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Web.WebPages.Razor" publicKeyToken="31bf3856ad364e35" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Web.WebPages.Deployment" publicKeyToken="31bf3856ad364e35" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" /> </dependentAssembly> </assemblyBinding> </runtime> <!-- Entity Framework Configuration. --> <entityFramework> <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" /> <providers> <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" /> </providers> </entityFramework> <elmah> <security allowRemoteAccess="yes" /> <errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="elmah-sql" applicationName="DocTrails" /> </elmah> </configuration> 

Edit: added some logging information

Thanks to the comments on this post, I double-checked in IIS where the logs are kept.

The screenshot below shows where the logs are saved:

enter image description here

According to another post here, in https://stackoverflow.com/a/3129/2/ , I know that the logs can also be found in the following location:

 C:\Windows\System32\LogFiles\HTTPERR 

So, I fulfilled a new request, and on the server again turned off the Just-In-Time Debugger Windows debugger several times (5, I think), but in both directories (the one shown in the screenshot and the one indicated above) , there are no files created or modified with the same timestamp as the request, so I could not find any additional information there.

Edit: added more information about further research

After some further research, I found out that the problem is not related to HTTPS, since starting the website in IIS via HTTP gives me the same error.

However, the Windows event log shows me the following entries:

 Faulting application name: w3wp.exe, version: 8.5.9600.16384, time stamp: 0x52157ba0 Faulting module name: clr.dll, version: 4.0.30319.34014, time stamp: 0x52e0b784 Exception code: 0xc00000fd Fault offset: 0x00003022 Faulting process id: 0xd00 Faulting application start time: 0x01d0452cb0b43b02 Faulting application path: C:\Windows\SysWOW64\inetsrv\w3wp.exe Faulting module path: C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll Report Id: f1876b51-b11f-11e4-8149-005056a1b9d2 Faulting package full name: Faulting package-relative application ID: 

Yours faithfully,

+6
source share
1 answer

After hours and hours of searching, I found a solution.

The code worked fine on my local computer, as the IIS application pool was configured to run a 64-bit application. On the server, it was configured to run 32-bit applications.

As soon as I changed it locally to 32 bits, I got a StackOverflowException and could start debugging.

It turned out to be a String object. I replaced it with StringBuilder, and now everything works fine.

+1
source

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


All Articles