- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我在我的 ASP.Net 应用程序中使用支付网关 API。在带有 XSP 的 MonoDevelop 中进行测试时,应用程序可以正常工作。当我将其配置为使用 mod_mono 在 apache2 中运行时,代码会因超时错误而不断崩溃。
对于在 Apache 而不是 XSP 中托管会发生什么变化,我感到很困惑。不管怎样,下面是超时的代码:
private string SubmitXml(string InputXml)
{
HttpWebRequest webReq = (HttpWebRequest)WebRequest.Create(_WebServiceUrl);
webReq.Method = "POST";
byte[] reqBytes;
reqBytes = System.Text.Encoding.UTF8.GetBytes(InputXml);
webReq.ContentType = "application/x-www-form-urlencoded";
webReq.ContentLength = reqBytes.Length;
webReq.Timeout = 5000;
Stream requestStream = webReq.GetRequestStream();
requestStream.Write(reqBytes, 0, reqBytes.Length);
requestStream.Close();
HttpWebResponse webResponse = (HttpWebResponse)webReq.GetResponse();
using (StreamReader sr = new StreamReader(webResponse.GetResponseStream(), System.Text.Encoding.ASCII))
{
return sr.ReadToEnd();
}
}
代码崩溃在线:Stream requestStream = webReq.GetRequestStream();
返回的错误是:
The request timed out
Description: HTTP 500. Error processing request.
Stack Trace:
System.Net.WebException: The request timed out at System.Net.HttpWebRequest.GetRequestStream () [0x0005f] in /private/tmp/monobuild/build/BUILD/mono-2.10.9/mcs/class/System/System.Net/HttpWebRequest.cs:746 at TCShared.PxPay.SubmitXml (System.String InputXml) [0x00048] in /Users/liam/Projects/techcertain/techcertaincsharp/Components/TCShared/PaymentGateways/Client/PxPay.cs:85 at TCShared.PxPay.GenerateRequest (TCShared.RequestInput input) [0x00015] in /Users/liam/Projects/techcertain/techcertaincsharp/Components/TCShared/PaymentGateways/Client/PxPay.cs:69
在我的 Web.Config 中,我将以下内容作为请求超时:
<httpRuntime executionTimeout="43200" maxRequestLength="104856" requestValidationMode="2.0" />
我已尝试更改 HttpWebRequest 的超时值,但它仍然超时。
发生这种情况的原因是什么,我该如何解决?
最佳答案
我设法找出我遇到这个问题的原因。它与 Apache 的使用完全无关。
我正在使用 Npgsql 访问 Postgresql 的数据库。 Npgsql 带有两个 dll(Npgsql.dll 和 Mono.Security.dll)。由于某些未知原因,Mono.Security.dll 导致 HttpWebRequest 在 Mono 上运行时超时。
无论如何,在 Mono 上运行时不需要 Mono.Security.dll,因为它已经包含在 Mono 框架中。因此,从我的 bin 目录中删除 Mono.Security dll 后,HttpWebRequest 就可以正常工作了。
这篇文章的全部功劳都在这里http://mono.1490590.n4.nabble.com/The-request-timed-out-at-HttpWebRequest-EndGetResponse-td2218213.html .
关于c# - Mono Apache2 HttpWebRequest 崩溃并显示 "The request timed out",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9952704/
我正在使用 HttpWebRequest 登录页面并获取一些信息。然后,我使用该信息创建一个新的 HttpWebRequest 以获取更多信息。我不想使用 WebClient。 如何将使用第一个 Ht
我有一个包含指向某些文件的链接的页面。 我基本上需要访问页面的源代码来解析它并获取文件的所有超链接。 我的代码是这样的(我在网上很多地方都找到了一些代码..): "private static
我正在编写一个渐进式下载器作为可移植类库 (Profile=24)。它将支持以字节 block 的形式部分下载目标文件。 HttpClient 不可用,我将使用 HttpWebRequest,它具有用
我正在努力在 HttpWebRequest 之上构建一个流畅的 REST 客户端界面。/HttpWebResponse .NET 中的类型。到目前为止,一切都很好......但是我正在尝试开发一个可插
我有一个用 VB.NET 编写的应用程序( 不是 asp.net,它是一个 Windows 控制台应用程序)。我正在尝试调用一个 url(一个 html 页面)并将响应返回到一个字符串中。响应是直接的
我尝试使用 C# HTTPWebRequest 类登录 amazon.com,我可以登录但无法读取 header 中的多个 set-cookie 当服务器响应多个“Set-Cookie:”-heade
我正在测试 Web 核心 API,但收到 500 内部服务器错误。 我的 Controller 上的方法是; [Route("api/property")] public class Property
假设我正在检索一个 url,如下所示: string url = "http://www.somesite.com/somepage.html" HttpWebRequest req = (HttpW
当我使用 HttpWebRequest.Headers.Add("Cookie",value) 与 HttpWebRequest.CookieContainer 和结果从 HttpWebRequest
我已阅读以下 2 篇文章并尝试实现相同的文章。 我的代码是这样的,超时发生在这里 HttpWebRequest wr = (HttpWebRequest)WebRequest.Create(url);
我正在寻找一种使用 httpWebRequest 从 url 下载 excel 文件并以某种方式解析它的方法 - 这是否意味着将其转换为 .csv 文件,以便我可以简单地使用 TextFieldPar
当我尝试序列化 HttpWebRequest 时出现以下错误 Type 'System.Net.KnownHttpVerb' in Assembly 'System, Version=2.0.0.0,
我目前正在下载一个 HTML 页面,使用以下代码: Try Dim req As System.Net.HttpWebRequest = DirectCast(WebRequest.Creat
我读了这个 MSDN 喜欢它并运行它的例子。 http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.useragent.a
我有一个 ASP.NET MVC 操作,它通过 HttpWebRequest 将 GET 请求发送到另一台服务器。我想在新请求中包含原始操作请求中的所有 cookie。原始请求中的一些 System.
我正在尝试抓取具有用户身份验证的网站。我能够执行POST来发送登录信息并存储Cookie。但是,登录后,尝试访问 protected 页面时出现403错误。 $url = "https://some_
我正在使用 HttpWebRequest ,并且正在处理响应流。 HttpWebRequest是否有正确的处理方法? ,因为它不包含 close 或 dispose 方法? 最佳答案 如果该类有特殊的
我在REST服务中抛出一个错误,例如: throw new WebFaultException("bla bla bla", HttpStatusCode.HttpVersionNotSuppo
问题:此控制台应用调用 Azure 上托管的长时间运行的网页两次。我希望它只调用一次。 控制台应用程序因捕获的异常而失败:基础连接已关闭:接收时发生意外错误。 so question 如果我从 Chr
我试图弄清楚我的网络请求在最终到达最终内容之前被重定向了多少次。 我正在创建我的网络请求,如下所示: var httpRequest = (HttpWebRequest) WebRequest.Cre
我是一名优秀的程序员,十分优秀!