简体   繁体   English

StreamReader,错误请求(400)

[英]StreamReader, Bad Request (400)

We have a website that allow firmware downloads. 我们有一个允许下载固件的网站。

Somwhere along the way it uses a StreamReader. 它沿途使用StreamReader。 For some unknown reason, some customer (In Israel) get a 400 Bad Request error. 由于某些未知原因,某些客户(在以色列)会收到400 Bad Request错误。 Everyone else do not get this error. 其他所有人都不会收到此错误。

Any1 out there experienced the same thing ? 那里的任何人都经历过同样的事情吗? Anyone got a clue ? 有人知道了吗?

protected void Page_Load(object sender, EventArgs e)
{
    string strURL = Request.Url.Host;
    System.Net.WebRequest reqPT = System.Net.WebRequest.Create("http://" + strURL + "/Products/ProductTree.asp");
    System.IO.StreamReader srPT = new System.IO.StreamReader(reqPT.GetResponse().GetResponseStream());
    dvPT.Controls.Add(new LiteralControl(srPT.ReadToEnd()));
}

It crashes, for them only, at the new StreamReader. 在新的StreamReader上,它仅对它们崩溃。

Thank you ! 谢谢 !

UPDATE : We noticed that the customer is actually loosing the "www" in the address (strURL), wich cause the error. 更新:我们注意到,客户实际上在地址(strURL)中丢失了“ www”,从而导致了错误。 Why would someone, (clicking on the same link as the rest of the planet is) would loose the www ?? 为什么有人(单击与地球其余部分相同的链接)会松散www? I'm seeing 2 differents behavior for the exact same code :S 我看到完全相同的代码有两种不同的行为:S

Well with the HTTP 400 error the requested URL is probably invalid, and since the literals in your System.Net.WebRequest look OK, my guess is your Israeli user is requesting the page using a different Request.Url.Host than everyone else. 由于HTTP 400错误,所请求的URL可能无效,并且由于System.Net.WebRequest的文字看起来正常,所以我想您的以色列用户正在使用与其他用户不同的Request.Url.Host请求页面。 Can you debug and verify the value of strUrl ? 您可以调试并验证strUrl的值吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM