相同代码代码在不同项目(console application,web form application)时,我用fiddler抓取http请求包
发现在web项目时请求的数据包被decode过了,而console项目不会这样且保持我传入的uri。
这是.net的bug吗?如果可以绕过这个decode?
public static string ReadFromUrl(string url)
{
string content = "";
WebResponse response = null;
StreamReader streamReader = null;
Stream receiveStream = null;
try
{
WebRequest request = WebRequest.Create(url);
response = request.GetResponse();
receiveStream = response.GetResponseStream();
streamReader = new StreamReader(receiveStream);
content = streamReader.ReadToEnd();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
finally
{
if (response != null)
{
response.Close();
}
streamReader.Close();
receiveStream.Close();
}
return content;
}
请求url为:
http://objstore.qa.nt.ctripcorp.com/smartemailstorage/2017%5C4%5C6%5Cf809530b-0ded-49b4-8532-002c7ad73b41%5C%E9%98%BF%E9%87%8C%E5%B7%B4%E5%B7%B4Java%E5%BC%80%E5%8F%91%E6%89%8B%E5%86%8C.pdf?AWSAccessKeyId=D1NNJCXLEF0O7JIB2U3L&Expires=1511426288&Signature=iJjQCreO6F7avac86Tg2S4e4Miw%3D
这是个内部链接,应该是访问不了,不过可以用fiddler抓包来获取请求的地址