我正在尝试对 JustOneDB 执行 https GET,如果我从 curl 实用程序执行此操作,它会起作用。但它不适用于 C#。我收到 (400) 错误请求
我四处搜索并禁用了安全性以及所有这些,但它仍然无法正常工作。有任何想法吗?有没有人用休息和 JustOneDB 做过这个?
这与所有其他其余示例一起工作:
curl -k -XGET 'https://username:password@77.92.68.105:31415/justonedb/database/database name'
这不起作用:我对字符串进行了模拟以删除我的密码。
public ActionResult JustOneDb()
{
///////////
HttpWebRequest request = null;
HttpWebResponse response = null;
try
{
String Xml;
//curl -k -XGET 'https://zn0lvkpdhdxb70l2_DUMMY_urshn5e7i41lb3fiwuh@77.92.68.105:31415/justonedb/database/n10lvkpdhdxei0l2uja'
string url = @"https://zn0lvkpdhdxb70_DUMMY_urshn5e7i41lb3fiwuh@77.92.68.105:31415/justonedb/database/n10lvkpdhdxei0l2uja";
request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "GET";
request.Credentials = CredentialCache.DefaultCredentials;
// Ignore Certificate validation failures (aka untrusted certificate + certificate chains)
ServicePointManager.ServerCertificateValidationCallback = ((sender, certificate, chain, sslPolicyErrors) => true);
// Get response
using (response = (HttpWebResponse)request.GetResponse())
{
// Get the response stream
StreamReader reader = new StreamReader(response.GetResponseStream());
Xml = reader.ReadToEnd();
}
return Content(Xml);
}
catch (Exception ee)
{
return Content(ee.ToString());
}
//////////////
ViewBag.fn = "*.xml";
return View();
}
结果:
System.Net.WebException: The remote server returned an error: (400) Bad Request. at System.Net.HttpWebRequest.GetResponse()
at Mvc3Razor.Controllers.MyXmlController.JustOneDb() ...
TIA FxM:{