如何检测Web服务器类型 [英] How to detect web server type

查看:130
本文介绍了如何检测Web服务器类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试检测哪种Web服务器类型正在运行域,那么处理此问题的最佳选择是什么.

I'm trying to detect which Web Server type is running a domain, so what are the best options to deal with this.

我正在做C#应用程序.

I'm doing a C# application.

推荐答案

您可以向服务器发出请求,并检查响应标头中" Server "的值

You could make a request to the server and check the response header for the value of "Server"

例如

using System;
using System.Net;

public class TestApp {
    public static void Main( string[] args ) {
        HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://www.stackoverflow.com/");
        WebResponse response = request.GetResponse();
        Console.Out.WriteLine( response.Headers.Get("Server") );
    }
}

// Output:
// Microsoft-IIS/7.0

这篇关于如何检测Web服务器类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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