C# 将JSon数据发布到服务器时的StackOverflowException(HTTP/HTTPS)
我有一个MVC网站,它在本地运行得很好。 当我调试应用程序时,当然,它是在HTTP协议下运行的,然后一切正常 我有一个控制器:C# 将JSon数据发布到服务器时的StackOverflowException(HTTP/HTTPS),c#,asp.net-mvc,angularjs,debugging,visual-studio-2013,C#,Asp.net Mvc,Angularjs,Debugging,Visual Studio 2013,我有一个MVC网站,它在本地运行得很好。 当我调试应用程序时,当然,它是在HTTP协议下运行的,然后一切正常 我有一个控制器: [Route("messages/new/form/invoice"), HttpPost] public ActionResult Invoice(object model) { var result = JsonConvert.DeserializeObject<dynamic>(model.ToString()); // Further
[Route("messages/new/form/invoice"), HttpPost]
public ActionResult Invoice(object model)
{
var result = JsonConvert.DeserializeObject<dynamic>(model.ToString());
// Further processing goes here...
}
通过我的视图调用此函数:
<form id="invoiceForm" name="invoiceForm" ng-submit="invoiceForm.$valid && invoiceCtrl.saveInvoice();" novalidate ng-init="invoiceCtrl.Init(@Model.FlowId)">
编辑:添加了一些有关日志记录的信息
<?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="<,>,%,&,:,\,?" 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>
多亏了这篇文章上的评论,我重新检查了IIS,日志保存在那里
下面的屏幕截图显示了日志的保存位置:
根据这里的另一篇帖子,我知道日志也可以在以下位置找到:
C:\Windows\System32\LogFiles\HTTPERR
因此,我执行了一个新的请求,在服务器上,即时调试器窗口再次打开了几次(我猜是5次),但在两个目录中(屏幕截图中定义的目录和上面列出的目录)都没有创建或修改与请求具有相同时间戳的文件,因此我在那里找不到更多信息
编辑:添加有关进一步调查的更多信息
经过进一步的调查,我发现这个问题与HTTPS无关,因为在IIS中使用HTTP协议运行该网站也会出现同样的错误
但是,Windows事件日志显示以下条目:
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:
亲切的问候,经过数小时的搜索,我找到了解决方案 由于IIS应用程序池配置为运行64位应用程序,因此代码在我的本地计算机上运行良好。在服务器上,它被配置为运行32位应用程序 一旦我在本地将其更改为32位,我确实收到了StackOverflowException并可以开始调试
原来是一个字符串对象。我已经用StringBuilder替换了它,现在一切正常。你不能远程连接到远程iis进程,看看问题出在哪里吗?这就是我正在做的,但是,我确实收到了StackOverflowException,甚至没有点击该方法。您是否使用任何代码从http重定向到https?请尝试在应用程序_BeginRequest()中设置调试器好的,也许您可以发布您的web.Config您指的是如何使用任何代码?我直接浏览到HTTPS协议下的网站。你认为我在哪里用代码做重定向。我只是在AngularJS函数中指向一个相对URL。
C:\Windows\System32\LogFiles\HTTPERR
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: