Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect web server type

Tags:

c#

webserver

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

I'm doing a C# application.


1 Answers

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

For example

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
like image 92
Abhinav Gupta Avatar answered Sep 01 '26 04:09

Abhinav Gupta



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!