English 中文(简体)
头盔检查 C#总是403?
原标题:Header Check C# is always 403?

如果存在一些领域——如果它们有一只nt子,就会有 p子,则试图绘制一份域清单,以获得初步的标识。 不是问题,但出于某种原因,转头也指背。

因此,试图获得http://unter responce of the special url.,但不管怎样,我得到403份答复。 是否有任何想法?

private void hunt_Click(object sender, EventArgs e)
    {
        listBox1.Items.Clear();
        string hostAddress = txtKeyword.Text;
        string combined;

        string[] strArray = new string[] { ".com", ".net", ".org", ".ca", ".gov" };

        foreach (string str in strArray)
        {

            combined = hostAddress + str;


            string result = string.Empty;
            try
            {
                Ping ping = new Ping();
                int timeout = 1500;
                PingReply pingreply = ping.Send(combined, timeout);


                if (pingreply != null && pingreply.Status.ToString() != "TimedOut")
                {
                    result = "Address: " + pingreply.Address + "
"
                         + "Roundtrip Time: " + pingreply.RoundtripTime + "
"
                         + "TTL (Time To Live): " + pingreply.Options.Ttl + "
"
                         + "Buffer Size: " + pingreply.Buffer.Length + "
";

                    listBox1.Items.Add(combined + " " + result);
                }
                else
                {

                    listBox1.Items.Add(combined + " not found");
                }

            }


            catch (Exception pingError)
            {
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://www."+combined);
                request.Method = "HEAD";
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                HttpStatusCode status = response.StatusCode;
                listBox1.Items.Add(status);
            }

        }
    }

thanks in advance

EDIT Ping error as follows:

System.Net.NetworkInformation.PingException: An exception occurred during a Ping     request. ---> System.Net.Sockets.SocketException: No such host is known
   at System.Net.Dns.GetAddrInfo(String name)
   at System.Net.Dns.InternalGetHostByName(String hostName, Boolean includeIPv6)
   at System.Net.Dns.GetHostAddresses(String hostNameOrAddress)
   at System.Net.NetworkInformation.Ping.Send(String hostNameOrAddress, Int32 timeout,     Byte[] buffer, PingOptions options)
   --- End of inner exception stack trace ---
   at System.Net.NetworkInformation.Ping.Send(String hostNameOrAddress, Int32 timeout,     Byte[] buffer, PingOptions options)
   at System.Net.NetworkInformation.Ping.Send(String hostNameOrAddress, Int32 timeout)
   at DomainHunter.Form1.hunt_Click(Object sender, EventArgs e) in 
最佳回答

Your logic appears to be backwards (as I read it anyway). If the ping throws an exception if it doesn t get a response then sending a HEAD request to the server is usually hopeless since the server probably doesn t exist.

除此以外,对于你重新努力完成的工作来说,这实际上不是一个好的选择。 您可在<代码>之间作出组合。 Dns.GetHost Addresses (如评论中所建议的),只是试图向80港和(或)443港(对于你试图检查的地点来说,这种连接一直适合)开放“TCP”与TCPClient的班,以确定实际上是否有一个接收所发现的IP的服务器。 几乎没有其他东西能够实际核实,实际上有一个服务器来倾听你们试图检查的IP。 如果URL在证明服务器后有效,可能的话是“,那么就会有良好的补充。

问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签