6

I do have an MVC website, which is running locally just fine. When I'm debugging the application, off course, it's running under the HTTP protocol then everything works fine.

I do 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've removed the code from this method here because it's irrelivant.

This method is called through AngularJS $http post service. This is done in the following way:

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 said previously, when running on my local computer, the code is working fine.

But now, I'm deploying it to a server where the website is running under the HTTPS protocol, which is off course different than HTTP on my local machine.

When I'm executing the code and I click the button to submit the form on the webserver, a new window open and that's the "Visual Studio Just In Time Debugger" asking me for an instance of Visual Studio to debug it, but Visual Studio is not installed on that server, which means I need to not select a debugger.

This window is showed to me 3 times. After cancelling all these debugger questions, in my webbrowser I do 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 does mean that the application pool has crashed.

So what I've tried right now is the following:

  • Deploying a DEBUG build to the server.
  • In the web.config changed the compilation debug to false.
  • Installed the Visual Studio remote debugger and remote debugged the application.

When I'm remote debugging the application, (meaning that I'm attaching to the remote IIS process) I'm setting my breakpoint on the very first line of the method in the post action (see my controller above). But, this method isn't hit at all, instead the remote debugging does throw a StackOverflowException as soon as I've hit the button to submit the form.

I'm hoping someone could point me in the right direction because I'm lost and it's driving me nuts for serveral hours.

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 information about logging

Thanks to the comments on this post, I've double checked in IIS, where the logs are being saved.

The screenshot below shows where the logs are being saved:

enter image description here

According to another post here on SO, I know that the logs could also be found in the following location:

C:\Windows\System32\LogFiles\HTTPERR

So, I've executed a new request, and on the server, again the Just-In-Time Debugger Windows opens for a few times (5 I guess), but in both directories, (the one defined in the screenshot, and the one listed above) there are no files created, nor modified with the same timestamp as the request, so I couldn't find any more information there.

Edit: Added some more information on further investigation

After some further investigation ,I've found out that the problem is not related to HTTPS, since running the website in IIS on the HTTP protocol 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: 

Kind regards,

Community
  • 1
  • 1
Complexity
  • 5,682
  • 6
  • 41
  • 84
  • can you not remotely attach to your remote iis process and see where the problem is? –  Feb 10 '15 at 10:23
  • That is what I'm doing, but then I do receive the StackOverflowException without even hitting the method. – Complexity Feb 10 '15 at 10:24
  • Do you use any code to redirect from http to https?Try set debugger in Application_BeginRequest() – vborutenko Feb 10 '15 at 10:25
  • ok maybe you can post your web.config –  Feb 10 '15 at 10:26
  • How do you mean using any code? I'm directly browsing to the website under the HTTPS protocol. Where do you think that I'm using any code to do a redirect. I'm only pointing to a relative URL in my AngularJS function. – Complexity Feb 10 '15 at 10:26
  • @FatGiant I've added the web.config file, however, removed the connection strings for security reasons. – Complexity Feb 10 '15 at 10:29
  • Not really... Your URL starts with a slash, meaning "starting at the root". So "/messages/new/form/invoice" and "messages/new/form/invoice" are not necessarily the same thing. – Roy Dictus Feb 10 '15 at 10:29
  • finally i would also suggest to fire up the iis logging –  Feb 10 '15 at 10:29
  • Ok, but I haven't ever used IIS logging. Do you mind pointing me in the right direction? – Complexity Feb 10 '15 at 10:30
  • for example.. http://stackoverflow.com/questions/6426375/where-can-i-find-the-iis-logs –  Feb 10 '15 at 10:31
  • Ok, I do have a look at the logs file and keep you posted through an update on the question. – Complexity Feb 10 '15 at 10:33
  • @FatGiant I've just fired a new request and checked 2 IIS logging directories. But no file has been created, nor modified with the same time of the request. – Complexity Feb 10 '15 at 10:37
  • hmmm...looks like its disabled then. it should create logs normally... –  Feb 10 '15 at 10:39
  • See my updated question, I've added a screenshot on how the logging is configured in IIS. I don't see anywhere that it's disabled. – Complexity Feb 10 '15 at 10:40
  • seem ok to me unless i miss something. however take a look into this as well..http://stackoverflow.com/questions/26849776/remote-require-https-mvc-5 .. unfortunately i dont know what else to suggest.. –  Feb 10 '15 at 10:50
  • I will have a look on it with the SysAdmin to see if we can disable HTTPS and then test it again. – Complexity Feb 10 '15 at 10:53

1 Answers1

1

After hours and hours of searching, I've found the solution.

The code was running fine on my local computer since the IIS application pool was configured to run 64 bit application. On the server it was configured for running 32 bit applications.

Once I changed it locally to 32 bit, I did receive the StackOverflowException and could start debugging.

It turned out that it was a String object. I've replaced it with a StringBuilder and everything works fine right now.

Complexity
  • 5,682
  • 6
  • 41
  • 84