试图达成一项Web服务URL从控制台应用程序返回500,工作(返回状态代码200如预期)没有问题,用简单的得到一个浏览器,但通过控制台应用程序执行的时候才返回状态代码500?我怀疑它的代理服务器或DNS的问题,但不确定...URL从浏览器的工作原理,但使用的HttpWebRequest
下面是从控制台应用程序请求创建:
// webRequestUrl has been modified
const string webRequestUrl = "http://0.0.0.0/communication/?id={0}&status=70"
var webRequest = WebRequest.Create(string.Format(webRequestUrl, invalidSseLead.LeadId));
try
{
using (var webResponse = (HttpWebResponse)webRequest.GetResponse())
{
if (webResponse != null && webResponse.StatusCode == HttpStatusCode.OK)
{
using (var textStream = new StreamWriter("updateQuery.sql", true))
{
// Write some text
}
}
}
}
catch (Exception exception)
{
// Report exception
}
已检查请求的URL生成和它的罚款,难倒为什么它从浏览器的工作原理,但不是控制台应用程序?
谢谢:)
如果你抓住的String.format的结果,并将其粘贴到浏览器是否有效? – msms 2011-02-01 23:03:10
是的,测试了这个,它的工作没有问题:( – timothyclifford 2011-02-01 23:06:02