是否可以从 shell 发送 HTTP DELETE 请求,如果可以,如何发送?
我办公室里的一些人在他们的颠覆项目中用#符号创建子文件夹.如:
https://subversion/Repo/Product/tags/version/Source/c#/FTP/bin/
Run Code Online (Sandbox Code Playgroud)
Subversion和TortoiseSVN对此没有任何问题,但是当我使用浏览器(或更具体地说HttpWebRequest)导航到它时,它会因为#在URL中无效而死亡.
是否有一些HTML代码或其他东西我可以#在代码中替换,以便我可以使用http从Subversion中提取文件?
我需要下载图像(验证码).这是一个例子.
如果你在任何浏览器中打开该链接它会显示一个图像,但是当我试图在代码中下载该图像时,它会给我一个html页面,其中只包含指向主页的链接 - http://www.networksolutions.com/.我究竟做错了什么?以下是两个代码示例:
byte[] data = new WebClient().DownloadData(imgURL);
AND
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(imgURL);
req.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
req.Headers.Add("Accept-Language", "en-us,en;q=0.5");
req.Headers.Add("Accept-Encoding", "gzip,deflate");
req.KeepAlive = true;
byte[] data;
using (HttpWebResponse response = (HttpWebResponse)req.GetResponse())
{
using (Stream s = response.GetResponseStream())
{
int contentLength = (int)response.ContentLength;
data = new byte[contentLength];
for (int pos = 0; pos < contentLength; ++pos)
{
int len = s.Read(data, pos, contentLength - pos);
pos += len;
}
}
}
Run Code Online (Sandbox Code Playgroud) 我有一个具有固定IP地址的站点,我通过HttpWebRequest对后端数据服务器方法进行c#调用.此后端系统将设置为仅允许来自我站点的IP固定地址的传入请求.
有没有办法将HttpWebRequest的IP地址设置为我的站点的IP(我怀疑我的云主机或.net以某种方式允许使用其他IP)?
我不是想欺骗IP; 我想确保我的asp.net代码使用网站自己的专用IP,或者至少检查它在发出请求时可能使用的IP.
我了解基本和摘要身份验证。但是我已经搜索了很多,并且在 NTLM、身份验证和协商方面遇到了困难。
我认为,如果我错了,请纠正我,NTLM 和身份验证是同一协议的两个术语。
协商首先尝试 NTLM,然后回退到消化,然后回退到基本连接。
那是对的吗?如果是这样,哪里有一个很好的例子,说明如何在 C# 中连接仅用于 NTLM 和协商。
我有两个用例。首先是我需要拉下一个文件。所以发出一个请求,得到一个 XML 文件作为响应,读下来,完成。
第二个是查询 OData 成百上千个 Web 请求,每个请求都将提供 JSON(或 XML)作为响应。
我遇到以下问题:
如果我使用网络浏览器打开地址https://info.protectiacivila.ro/test.php
,则显示文本“Hello!” 被展示。
我在 Windows 窗体应用程序中编写了以下单击事件处理程序(目标:.NET 4.5):
private void button1_Click(object sender, EventArgs e) {
Uri uri = new Uri("https://info.protectiacivila.ro/test.php");
ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls12;
HttpWebRequest request = WebRequest.Create(uri) as HttpWebRequest;
try {
string strResponse;
using (HttpWebResponse response = request.GetResponse() as HttpWebResponse) {
StreamReader reader = new StreamReader(response.GetResponseStream());
strResponse = reader.ReadToEnd();
}
MessageBox.Show(strResponse);
} catch (Exception ex) {
MessageBox.Show(ex.Message);
}
}
Run Code Online (Sandbox Code Playgroud)
上面的方法应该显示消息“Hello!”
它在Windows 10中完美运行。这意味着SSL证书是有效的。
但是,在 Windows 7 中,它会显示错误消息:
请求已中止:无法创建 SSL/TLS 安全通道。
我该怎么做才能使上述方法在 Windows 7 中也起作用?
谢谢
我有以下代码登录到POST http://www.160by2.com/logincheck.aspx?iamindian=这个网址,我的问题是我无法登录,当我使用Fiddler调试它时,我看不到ne cookie认为我正在使用CookieContainer类,这里我在c#中使用Windows应用程序
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://www.160by2.com/logincheck.aspx?iamindian=");
string PostData = string.Format("htxt_UserName={0}&txt_Passwd={1}&txt_pop=&s=&d=&cmdSubmit=&namenumber={2}&strclf=&strshareuser=&ucountry=&ucode=&ucity=&uregion=", txtMobile.Text, txtPassword.Text, "1");
CookieContainer cookie = new CookieContainer();
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.Referer = "http://www.160by2.com";
request.CookieContainer = cookie;
StreamWriter sWriter = new StreamWriter(request.GetRequestStream());
sWriter.Write(PostData);
sWriter.Close();
request.GetResponse().Close();
//some more code is here for further posting but above code can't login so below code is also not working
Run Code Online (Sandbox Code Playgroud)
我跟着这个,发帖但是它对我没有帮助..请帮帮我,这里我的错误..
我正在用C#开发一个Windows应用程序,我还开发了一个asp.net网站并托管在服务器中.我的动机是不向用户显示我的服务器源或域地址.
因此我在c#(win app)中设计了一个自定义浏览器,然后我将用户导航到我的asp.net网站.我没有保留地址栏,我在该浏览器中禁用了右键单击选项.因此用户只能查看页面,无法找到服务器信息.
但我现在面临的问题是,当用户尝试从网站下载任何内容时,Internet Explorer的下载窗口会打开并询问保存位置.但是在屏幕上它向用户显示我的服务器IP或域地址.那么我该如何向用户隐藏它,或者你可以请我解决我的问题.即(我不想向我的用户显示我的服务器信息,但我希望他们从我的网站下载或保存)
我正在尝试创建一个将url作为参数并从中返回GET响应的函数,它只是WebResponse responseObject intialization在行中给出了一个错误
例外是 An exception of type 'System.Net.ProtocolViolationException' occurred in mscorlib.ni.dll but was not handled in user code
public static async Task<string> get(string url)
{
var request = WebRequest.Create(new Uri(url)) as HttpWebRequest;
request.Method = "GET";
request.ContentType = "application/json";
WebResponse responseObject = await Task<WebResponse>.Factory.FromAsync(request.BeginGetResponse, request.EndGetResponse, request);
var responseStream = responseObject.GetResponseStream();
var sr = new StreamReader(responseStream);
string received = await sr.ReadToEndAsync();
return received;
}
Run Code Online (Sandbox Code Playgroud) 我对JAVA完全陌生。我需要编写一个servlet,它将使用从客户端发送的http post参数。我已经有一个Java应用程序平台服务器,可以在其中部署我的应用程序。我需要编写一个servlet,它将对发布的参数做出反应。
显然我需要在Servlet中公开这些变量?我做了谷歌,并遇到了建议使用REST框架来实现这一目标的结果。如果不使用任何其他框架,是否不可能编写平面Java代码(例如要运行Tomcat)?样本或教程的链接也将很有帮助。
谢谢
您好我已经创建了WCF服务,服务合同和数据合同粘贴在下面
[ServiceContract]
public interface IRestWithXML
{
[OperationContract]
[WebInvoke(Method = "Post", UriTemplate = "DoWork", RequestFormat= WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
string DoWork(Test objtest);
[OperationContract]
[WebInvoke(Method = "Post", UriTemplate = "Method?test={strtest}", BodyStyle = WebMessageBodyStyle.Wrapped, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
string Method(Test objtest,string strtest);
}
[DataContract]
public class Test
{
[DataMember]
public string id { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我应该如何在.NET中测试这些服务.我可以通过将方法"Post"更改为"GET"来测试方法.
但我必须使用"Post"来测试这些服务.请指导我
提前致谢 !!!!