如何解决无法在本地连接到远程服务器
string url = ConfigurationManager.AppSettings["CorreURL"].ToString(); https://ourwebsite.com/Transmit
string json = JsonConvert.SerializeObject(claim,Formatting.Indented);
WebRequest request = WebRequest.Create(url);
request.ContentType = "application/json";
request.Method = "GET";
request.Headers.Add("Authorization","passwordgoesherebuthiddenfromstackoverflow");
Type type = request.GetType();
Object currentMethod = type.GetProperty("CurrentMethod",BindingFlags.NonPublic | BindingFlags.Instance).GetValue(request);
Type methodType = currentMethod.GetType();
methodType.GetField("ContentBodyNotAllowed",BindingFlags.NonPublic | BindingFlags.Instance).SetValue(currentMethod,false);
//i get the error here:
using (StreamWriter streamWriter = new StreamWriter(request.GetRequestStream()))
{
streamWriter.Write(json);
}
我想做的是向我们的服务器发送一个 json 文件(该文件没问题,因为我在 lint 上对其进行了测试)以处理该文件。我们使用邮递员,我从那里得到了信用,但没有运气。我希望这是足够的信息。如果我需要提供更多信息,请告诉我。上面的代码就是刚才隐藏的所有代码。
提前致谢
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。