我在ASP.Net應用程序中使用支付網關API。在使用XSP進行MonoDevelop測試時,應用程序可以正常工作。當我將它配置爲使用mod_mono在apache2中運行時,代碼會因超時錯誤而崩潰。Mono Apache2 HttpWebRequest與「請求超時」崩潰
我很遺憾,在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();
錯誤返回是:HTTP 500.錯誤處理請求。
堆棧跟蹤:
System.Net.WebException:請求在 System.Net.HttpWebRequest.GetRequestStream超時()[0x0005f]在 /私人/ TMP/monobuild /建造/ BUILD /單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/TC共享/ PaymentGateways /客戶/ PxPay.cs:69
在我的web.config我有以下爲請求超時:
<httpRuntime executionTimeout="43200" maxRequestLength="104856" requestValidationMode="2.0" />
我曾嘗試在HttpWebRequest的,但它改變了超時值仍然是超時。
是什麼導致這種情況發生,我該如何解決?
嘿,我有同樣的問題,你只有刪除Mono.Security沒有修復它。這在兩個不同的linux安裝中是一致的,並且贏得單聲道也是如此。你有什麼想法我應該嘗試嗎? – Pablote 2012-04-16 00:21:28
嗨,你可以嘗試使用不同版本的單聲道。我在我的Mac上使用2.10.8版,HttpWebRequest正在運行。當我將單聲道升級到版本2.10.9時,HttpWebRequest停止工作,因此我必須降級到2.10.8。 – startupsmith 2012-04-17 04:36:45
正在刪除Mono.Security。DLL爲我解決了這個問題,但是你需要確保你從源文件夾(項目引用指向的地方)以及你的Bin/Debug | Release文件夾中的任何文件夾中刪除它,因爲它會從之前的版本。 – t9mike 2012-11-12 00:03:44