请求和响应问题 [英] Problem with Request and response

查看:78
本文介绍了请求和响应问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前面临的问题是从以下URL中提取User:Password:
HTTPS://User:Password@www.myURL.com/default.aspx?address = xyz& phone = 234563

请求方法是POST.上面示例的实现如下:
我有两页,一个创建一个REquest对象,另一页使用Request.Url.toString()
获取请求
发送请求的页面的代码如下:

The problem that I am facing at the moment is to extract User:Password fromt he following URL :
HTTPS://User:Password@www.myURL.com/default.aspx?address=xyz&phone=234563

Request Method is POST. Implementation of the above example is done as follows:
I have two pages one Creates a REquest object and the other page Gets the Request using Request.Url.toString()

The code for the page sending the request is as follows:

HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http://User:Password@localhost:2721/TestWebApp/Default.aspx");
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
string strNewValue = @"&MessageId=123&DestinationAddress=46762050312";
req.ContentLength = strNewValue.Length;
// Write the request
StreamWriter stOut = new StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII);
stOut.Write(strNewValue);
stOut.Close();
HttpWebResponse res = (HttpWebResponse) req.GetResponse();
Stream resst = res.GetResponseStream();
StreamReader sr = new StreamReader(resst);
string response = sr.ReadToEnd();
Response.Write(response);


接收请求的页面编码如下:


Page receiving the request is coded as follows:

string    str = Request.Url.ToString();


在收到请求时,"str"仅包含: http://localhost:2721/TestWebApp/Default.aspx
用户:密码丢失.


请让我知道如何从上述URL中检索用户名和密码.


On receiving the request "str" only contains: http://localhost:2721/TestWebApp/Default.aspx
User: Password is missing .


Please let me know how can I retrieve the USer and password from above URL.

推荐答案

对恶意软件存在一些担忧之后,该用户可以在用户名和密码组合中使用用户名和密码.在IE中,默认情况下禁用了url.因此,浏览器会在发布之前删除此内容.

可以重新启用它,但不建议使用该方法来传输信息.

请参阅Microsoft的此支持文章;
http://support.microsoft.com/kb/834489 [
Following some concerns with malicious software, the ability to use username and password combinations in the url was disabled by default in IE. As such the browser strips this before posting.

It can be re-enabled, but is not recommended method of transporting the info.

See this Support Article at Microsoft;
http://support.microsoft.com/kb/834489[^]


这篇关于请求和响应问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆