- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我有一个 MVC 网站,它在本地运行得很好。当我调试应用程序时,当然,它在 HTTP 协议(protocol)下运行,然后一切正常。
我有一个 Controller :
[Route("messages/new/form/invoice"), HttpPost]
public ActionResult Invoice(object model)
{
var result = JsonConvert.DeserializeObject<dynamic>(model.ToString());
// Further processing goes here...
}
注意:我在这里删除了此方法中的代码,因为它无关紧要。
这个方法是通过 AngularJS $http post 服务调用的。这是通过以下方式完成的:
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);
});
}
这个函数是通过我的 View 调用的:
<form id="invoiceForm" name="invoiceForm" ng-submit="invoiceForm.$valid && invoiceCtrl.saveInvoice();" novalidate ng-init="invoiceCtrl.Init(@Model.FlowId)">
但是,如前所述,在我的本地计算机上运行时,代码运行良好。
但现在,我将其部署到网站在 HTTPS 协议(protocol)下运行的服务器,这当然不同于我本地计算机上的 HTTP。
当我执行代码并单击按钮以在网络服务器上提交表单时,一个新窗口打开,这是“Visual Studio 即时调试器”,要求我提供一个 Visual Studio 实例来调试它,但该服务器上未安装 Visual Studio,这意味着我不需要选择调试器。
这个窗口向我显示了 3 次。取消所有这些调试器问题后,在我的网络浏览器中,我确实在控制台中看到以下内容:
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>
这确实意味着应用程序池已崩溃。
所以我现在尝试的是以下内容:
当我远程调试应用程序时,(意味着我附加到远程 IIS 进程)我在 post 操作中的方法的第一行设置断点(参见上面的 Controller )。但是,这个方法根本没有被命中,而是远程调试确实在我按下按钮提交表单后立即抛出一个 StackOverflowException
。
我希望有人能给我指出正确的方向,因为我迷路了,这让我发疯了好几个小时。
编辑:添加了 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="<,>,%,&,:,\,?" 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 中仔细检查了保存日志的地方。
下面的屏幕截图显示了日志的保存位置:
根据此处的另一篇帖子 SO ,我知道日志也可以在以下位置找到:
C:\Windows\System32\LogFiles\HTTPERR
所以,我执行了一个新请求,在服务器上,即时调试器窗口再次打开了几次(我猜是 5 次),但是在两个目录中,(在屏幕截图中定义的那个) ,以及上面列出的那个)没有创建文件,也没有使用与请求相同的时间戳修改文件,所以我在那里找不到更多信息。
编辑:添加了一些关于进一步调查的更多信息
经过进一步调查,我发现问题与 HTTPS 无关,因为在 IIS 中以 HTTP 协议(protocol)运行网站会出现同样的错误。
但是,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 并且可以开始调试。
原来是String对象。我已将其替换为 StringBuilder,现在一切正常。
关于c# - 将 JSON 数据发布到服务器 (HTTP/HTTPS) 时发生 StackOverflowException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28429149/
dataElementsList : TypesAndData.DataElement list 是一个包含 50,000 条记录的列表(实际上更多,但让我们从小处开始)。我正在尝试序列化为 JSON
我试图序列化一个自定义类型,该类型在其他成员中包含一个字典。与字典的键和值相关联的类型是实现的接口(interface)。 字典看起来像 Dictionary TypeA implements IT
我有一个 C# 工厂对象,它使用对象列表作为源,通过工厂方法创建对象。 对象列表的创建方式如下: public WidgetFactory() { widgetLibrary
我正在 GenericList 类中实现递归快速排序方法。我将有第二种方法,它接受一个compareDelegate来比较不同的类型,但出于开发目的,我对GenericList进行排序。 我根据列表大
我为我的作业编写了一种方法,用于通过递归计算整数数组的所有排列。 (我正在尝试实现回溯算法)。但计算超过 7 个数字的前突变时会导致 StackOverflowException 。我不知道如何解决这
我正在尝试将一个大文件拆分成许多小文件。每个拆分发生的位置基于检查每个给定行的内容返回的谓词(isNextObject 函数)。 我试图通过 File.ReadLines 函数读取大文件,这样我就可以
我正在使用 onSuccessCallBack() 接口(interface)方法同步大量数据。按照如图所示的方法将数据发送到服务器。在这里我面临 StackOverflowException 的问题
我必须递归调用一个函数。但片刻之后它会抛出 StackOverFlowException。当我使用 Invoke(new Action(Start)) 方法时,它会抛出相同的异常,但不会在很长一段时间
我有一些依赖于 HttpContext.Cache 的代码,我希望它在满足特定条件时重新缓存某些内容。但是,这会引入潜在的堆栈溢出,我不确定这里的适当方法是什么。 看看这段代码: void OnCac
我将我的代码剥离到导致问题的部分。代码在这里来回跳转第5行和第9行,导致stackoverflowexception。 我该如何做呢?我需要 Game 类中的 Platform 实例才能在函数中使用。
我的问题很简单。我有这个新表格,我只是编写代码: public partial class Form1 : Form { public Form1() { In
根据我的question (通用方法的可重用非通用方法)我已经实现了提供的解决方案,但经过一些重构(将代码移动到基类)后,我的代码导致了我不理解的 StackOverflowException。 调用
背景。我的脚本在递归搜索大字符串中的特定文本时遇到 StackOverflowException。循环不是无限的;问题发生在 9,000-10,000 次合法搜索之间(对于特定搜索)——我需要它继续进
请帮助我解决 System.StackOverflowException我想用 .aspx 将记录写入数据库我使用 4 层架构来实现这一切都正常但是当我编译页面然后它显示要插入数据的字段时,当我将数据
我正在尝试回答 my own old question基于我唯一的(无效的)答案。 这个想法是为了简化按值排序的映射的创建: public class SortedByValueMap> implem
我目前正在制作有界数组堆栈。此方法将大于存储容量的数组抛出到 StackOverflowException,除了我不断收到“throws StackOverflowException 部分”的错误消息
我正在使用以下方法递归迭代对象的属性: void GetProps(object obj) { if (obj == null) return; var objType
我想做一个非常简单的任务,它以某种方式使程序崩溃。 我有一个包含数字的列表,所有数字都是唯一的。超过一定数量,我想倒序。 示例:5, 16, 11, 3, 8, 4 -> 5, 16, 11, 4,
我正在尝试编写一个函数来检查字符串是否为回文,并使用 this example ,我正在尝试使用递归匿名函数反转字符串: static Boolean checkPalindromeAnonRec(s
这段代码有什么问题?我不断收到 StackOverlflowException.. public class Places { public string Title { get; set;
我是一名优秀的程序员,十分优秀!