<small id='AjVW2'></small><noframes id='AjVW2'>

<tfoot id='AjVW2'></tfoot>
    <bdo id='AjVW2'></bdo><ul id='AjVW2'></ul>

  • <legend id='AjVW2'><style id='AjVW2'><dir id='AjVW2'><q id='AjVW2'></q></dir></style></legend>
  • <i id='AjVW2'><tr id='AjVW2'><dt id='AjVW2'><q id='AjVW2'><span id='AjVW2'><b id='AjVW2'><form id='AjVW2'><ins id='AjVW2'></ins><ul id='AjVW2'></ul><sub id='AjVW2'></sub></form><legend id='AjVW2'></legend><bdo id='AjVW2'><pre id='AjVW2'><center id='AjVW2'></center></pre></bdo></b><th id='AjVW2'></th></span></q></dt></tr></i><div id='AjVW2'><tfoot id='AjVW2'></tfoot><dl id='AjVW2'><fieldset id='AjVW2'></fieldset></dl></div>

      1. System.Net.WebClient 请求获得 403 Forbidden 但浏览器不使用 Apache 服务器

        System.Net.WebClient request gets 403 Forbidden but browsers do not with Apache servers(System.Net.WebClient 请求获得 403 Forbidden 但浏览器不使用 Apache 服务器)
          <i id='CZDiQ'><tr id='CZDiQ'><dt id='CZDiQ'><q id='CZDiQ'><span id='CZDiQ'><b id='CZDiQ'><form id='CZDiQ'><ins id='CZDiQ'></ins><ul id='CZDiQ'></ul><sub id='CZDiQ'></sub></form><legend id='CZDiQ'></legend><bdo id='CZDiQ'><pre id='CZDiQ'><center id='CZDiQ'></center></pre></bdo></b><th id='CZDiQ'></th></span></q></dt></tr></i><div id='CZDiQ'><tfoot id='CZDiQ'></tfoot><dl id='CZDiQ'><fieldset id='CZDiQ'></fieldset></dl></div>

            <bdo id='CZDiQ'></bdo><ul id='CZDiQ'></ul>

                <tbody id='CZDiQ'></tbody>

            1. <small id='CZDiQ'></small><noframes id='CZDiQ'>

              <tfoot id='CZDiQ'></tfoot>

                  <legend id='CZDiQ'><style id='CZDiQ'><dir id='CZDiQ'><q id='CZDiQ'></q></dir></style></legend>
                  本文介绍了System.Net.WebClient 请求获得 403 Forbidden 但浏览器不使用 Apache 服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  奇怪的是,我正在尝试阅读 <Head>许多不同网站的部分,一种特定类型的服务器,Apache,有时会给出代码 403 禁止.并非所有 apache 服务器都这样做,因此它可能是配置设置或服务器的特定版本.

                  An odd one, I'm trying to read the <Head> section of a lot of different websites out there, and one particular type of server, Apache, sometimes gives the code 403 forbidden. Not all apache servers do this, so it may be a config setting or a particular version of the server.

                  然后,当我使用网络浏览器(例如 Firefox)检查 url 时,页面加载正常.代码如下所示:

                  When I then check the url with a web browser (Firefox, for example) the page loads fine. The code sorta looks like this:

                  var client = new WebClient();
                  var stream = client.OpenRead(new Uri("http://en.wikipedia.org/wiki/Barack_Obama"));
                  

                  通常,403 是访问权限失败之类的事情,但这些通常是不安全的页面.我认为 Apache 正在过滤请求标头中的某些内容,因为我不想创建任何内容.

                  Normally, a 403 is a access permission failed sort of thing, but these are normally unsecure pages. I'm thinking that Apache is filtering on something in the request headers since I'm not bothering to create any.

                  也许对 Apache 有更多了解的人可以给我一些关于标题中缺少的内容的想法.我想保持标题尽可能小以最小化带宽.

                  Maybe someone who knows more about Apache can give me some ideas of what's missing in the headers. I'd like to keep the headers as small as possible to minimize bandwidth.

                  谢谢

                  推荐答案

                  尝试设置 UserAgent 标头:

                  Try setting the UserAgent header:

                  string _UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)";
                  client.Headers.Add(HttpRequestHeader.UserAgent, _UserAgent);
                  

                  这篇关于System.Net.WebClient 请求获得 403 Forbidden 但浏览器不使用 Apache 服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Adding and removing users from Active Directory groups in .NET(在 .NET 中的 Active Directory 组中添加和删除用户)
                  How do you determine if two HashSets are equal (by value, not by reference)?(您如何确定两个 HashSet 是否相等(按值,而不是按引用)?)
                  Is there a quot;Setquot; data structure in .Net?(有没有“套路?.Net 中的数据结构?)
                  Collection that allows only unique items in .NET?(仅允许 .NET 中唯一项目的集合?)
                  Adding HTTP Headers and Post data in a System.Windows.Forms.WebBrowser(在 System.Windows.Forms.WebBrowser 中添加 HTTP 标头和发布数据)
                  Adding headers in ASP.NET MVC 3(在 ASP.NET MVC 3 中添加标头)
                    <tbody id='NiAFP'></tbody>
                • <small id='NiAFP'></small><noframes id='NiAFP'>

                    <i id='NiAFP'><tr id='NiAFP'><dt id='NiAFP'><q id='NiAFP'><span id='NiAFP'><b id='NiAFP'><form id='NiAFP'><ins id='NiAFP'></ins><ul id='NiAFP'></ul><sub id='NiAFP'></sub></form><legend id='NiAFP'></legend><bdo id='NiAFP'><pre id='NiAFP'><center id='NiAFP'></center></pre></bdo></b><th id='NiAFP'></th></span></q></dt></tr></i><div id='NiAFP'><tfoot id='NiAFP'></tfoot><dl id='NiAFP'><fieldset id='NiAFP'></fieldset></dl></div>

                    <tfoot id='NiAFP'></tfoot>

                      • <legend id='NiAFP'><style id='NiAFP'><dir id='NiAFP'><q id='NiAFP'></q></dir></style></legend>
                        • <bdo id='NiAFP'></bdo><ul id='NiAFP'></ul>